結果

問題 No.154 市バス
ユーザー oxyshoweroxyshower
提出日時 2020-01-23 11:47:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 174,964 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 02:08:00
合計ジャッジ時間 2,640 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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, counter = false;
    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']--;
        }
        counter = false;
      }
      if(s[j] == 'W'){
        mp['W']++;
        counter = true;
      }
    }
    if(judge && mp['G'] == mp['R'] && mp['G'] != 0 && !counter){
      cout << "possible" << endl;
    }else{
      cout << "impossible" << endl;
    }
  }

  return 0;
}
0