結果
| 問題 | 
                            No.154 市バス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             oxyshower
                         | 
                    
| 提出日時 | 2020-01-23 11:14:42 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 817 bytes | 
| コンパイル時間 | 1,741 ms | 
| コンパイル使用メモリ | 175,492 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-18 17:42:37 | 
| 合計ジャッジ時間 | 2,720 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 6 WA * 2 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int unsigned 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'] == 0){
          judge = false;
        }else{
          mp['G']--;
        }
      }
      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'] == 0){
      cout << "possible" << endl;
    }else{
      cout << "impossible" << endl;
    }
  }
  return 0;
}
            
            
            
        
            
oxyshower