結果
| 問題 | 
                            No.154 市バス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-10-19 14:02:12 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,046 bytes | 
| コンパイル時間 | 1,653 ms | 
| コンパイル使用メモリ | 166,860 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-27 03:11:11 | 
| 合計ジャッジ時間 | 2,883 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 6 WA * 2 | 
ソースコード
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    int T;
    cin >> T;
    for(int i = 0;i < T;i++){
        string s;
        cin >> s;
        bool ans = true;
        int w = 0, g = 0, r = 0;
        for(int j = 0;j < s.size();j++){
            if(s[j] == 'W'){
                w++;
            }else if(s[j] == 'G'){
                g++;
                if(g > w)   ans = false;
            }else{
                r++;
                if(r > g)   ans = false;
            }
        }
        if(r != g)  ans = false;
        if(ans) cout << "possible" << endl;
        else    cout << "impossible" << endl;
    }
}