結果

問題 No.154 市バス
ユーザー hogeover30hogeover30
提出日時 2016-06-12 00:16:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 67,824 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 09:34:17
合計ジャッジ時間 1,174 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    int T; cin>>T;
    while (T--) {
        string s; cin>>s;
        reverse(begin(s), end(s));

        int cnt[128]={};
        bool res=true;
        for(auto& c: s) {
            ++cnt[c];
            if (c=='W' and cnt['G']==0)
                res=false;
            else if (c=='G' and cnt['R']<cnt['G'])
                res=false;
        }
        if (cnt['R']==0 or cnt['R']!=cnt['G'] or cnt['W']<cnt['R'])
            res=false;

        cout<<(res ? "possible" : "impossible")<<endl;
    }
}
0