結果

問題 No.154 市バス
ユーザー LayCurseLayCurse
提出日時 2015-02-17 01:51:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 1,389 ms
コンパイル使用メモリ 158,056 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 07:30:48
合計ジャッジ時間 2,391 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 76 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int T;
string S;

int main(){
  int i, j, k;
  int W, G, R;

  cin >> T;
  while(T--){
    cin >> S;
    for(;;){
      rep(R,S.size()) if(S[R]=='R') break;
      if(R==S.size()) break;
      for(G=R;G>=0;G--) if(S[G]=='G') break;
      if(G<0) break;
      for(W=G;W>=0;W--) if(S[W]=='W') break;
      if(W<0) break;

      if(R==S.size()-1 && G==S.size()-2){
        rep(i,G) if(S[i]!='W') break;
        if(i==G) S = "";
        break;
      }

      S.erase(S.begin()+R);
      S.erase(S.begin()+G);
      S.erase(S.begin()+W);
    }
    if(S.size()==0) puts("possible"); else puts("impossible");
  }

  return 0;
}
0