結果

問題 No.154 市バス
ユーザー yomayoma
提出日時 2019-10-19 14:02:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,046 bytes
コンパイル時間 1,685 ms
コンパイル使用メモリ 165,992 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 10:01:29
合計ジャッジ時間 3,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
    }
}
0