結果

問題 No.154 市バス
ユーザー 0w10w1
提出日時 2016-11-21 00:18:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 165,252 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 10:00:45
合計ジャッジ時間 2,948 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

const string msg[] = { "impossible", "possible" };

signed main(){
  int T; cin >> T;
  for( int i = 0; i < T; ++i ){
    int ng = 0;
    string S; cin >> S;
    int w = 0, g = 0, r = 0, zg = 0;
    for( int j = S.size() - 1; j >= 0; --j ){
      if( S[ j ] == 'R' ) ++r;
      if( S[ j ] == 'G' ){
        if( --r < 0 ) ng = 1;
        ++g, ++zg;
      }
      if( S[ j ] == 'W' ){
        if( g == 0 ) ng = 1;
        --zg;
      }
    }
    ng |= zg > 0;
    cout << msg[ not ng ] << endl;
  }
  return 0;
}
0