結果

問題 No.154 市バス
ユーザー satanicsatanic
提出日時 2016-05-06 23:24:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 70,040 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:27:46
合計ジャッジ時間 1,560 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int t;
    std::cin >> t;
    for(int i=0; i<t; ++i){
        std::vector<int> imos;
        std::string str;
        std::cin >> str;
        for(auto c : str){
            switch(c){
                case 'G': imos.push_back( 1); break;
                case 'R': imos.push_back(-1); break;
            }
        }
        std::cout << (([&]() -> bool {
            if(imos[0]==-1) return false;
            for(size_t j=1; j<imos.size(); ++j){
                imos[j] += imos[j-1];
                if(imos[j]<0) return false;
            }
            if(imos.back()!=0) return false;
            return true;
        }())? "possible\n" : "impossible\n");
    }
        
    return 0;
}
0