結果

問題 No.154 市バス
ユーザー capythmcapythm
提出日時 2016-06-20 00:29:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 55,132 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:45:47
合計ジャッジ時間 1,517 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,248 KB
testcase_01 AC 9 ms
5,376 KB
testcase_02 AC 8 ms
5,376 KB
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 5 ms
5,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  int T;
  string S;
  cin >> T;
  for( int i=0; i<T; i++ ){
    cin >> S;
    int d[3] = {0,0,0};
    bool f = true;
    for( int i=S.size()-1; i>=0; i-- ){
      switch( S[i] ){
        case 'R':
          d[0]++;
          break;
        case 'G':
          if( d[0] == 0 ){
            f = false;
          } else {
            d[0]--;
            d[1]++;
          }
          break;
        case 'W':
          if( d[1] > 0 ){
            d[1]--;
            d[2]++;
          } else if( d[2] == 0 ) {
            f = false;
          }
          break;
      }
      if( !f ) break;
    }
    if( f ) cout << "possible" << endl;
    else cout << "impossible" << endl;
  }
}
0