結果

問題 No.154 市バス
ユーザー ngtkanangtkana
提出日時 2020-04-06 01:07:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 199,692 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 05:32:16
合計ジャッジ時間 2,657 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint q;std::cin>>q;
    while(q--){
        std::string s;std::cin>>s;
        lint r=0,g=0,w=0;
        bool ng=false;
        for(char c:std::string(s.rbegin(),s.rend())){
            (c=='R'?r:c=='G'?g:w)++;
            ng|=r<g||!g&&w;
            if(g<w)w=g;
        }
        ng|=r!=g||w!=g;
        std::cout<<(ng?"impossible":"possible")<<'\n';
    }
}
0