結果

問題 No.154 市バス
ユーザー cureskol
提出日時 2020-04-09 11:02:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 167,468 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 20:48:00
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  int n;cin>>n;
  while(n--){
    bool out=false;
    string s;cin>>s;
    reverse(s.begin(),s.end());
    int r=0,b=0;
    for(auto p:s){
      if(p=='R')r++;
      if(p=='G'){
        r--;
        chmax(b,0);b++;
        if(r<0)out=1;
      }
      if(p=='W')b--;
    }
    if(r||b>0)out=1;
    cout<<(out?"impossible":"possible")<<endl;
  }
}
0