結果

問題 No.154 市バス
ユーザー hogeover30
提出日時 2016-06-12 00:16:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 67,584 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 08:27:23
合計ジャッジ時間 1,270 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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