結果

問題 No.154 市バス
ユーザー oxyshoweroxyshower
提出日時 2020-01-23 11:37:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 174,312 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 23:59:43
合計ジャッジ時間 2,956 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    map<char, int> mp;
    mp['W'] = 0, mp['G'] = 0, mp['R'] = 0;
    bool judge = true;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == 'R'){
        if(mp['G'] == mp['R']){
          judge = false;
        }else{
          mp['R']++;
        }
      }
      if(s[j] == 'G'){
        mp['G']++;
        if(mp['W'] == 0){
          judge = false;
        }else{
          mp['W']--;
        }
      }
      if(s[j] == 'W'){
        mp['W']++;
      }
    }
    if(judge && mp['G'] == mp['R'] && mp['G'] != 0){
      cout << "possible" << endl;
    }else{
      cout << "impossible" << endl;
    }
  }

  return 0;
}
0