結果
問題 | No.154 市バス |
ユーザー | hogeover30 |
提出日時 | 2016-06-12 02:20:59 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 857 bytes |
コンパイル時間 | 703 ms |
コンパイル使用メモリ | 69,032 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-21 09:34:39 |
合計ジャッジ時間 | 1,612 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
6,816 KB |
testcase_01 | AC | 29 ms
6,940 KB |
testcase_02 | AC | 29 ms
6,940 KB |
testcase_03 | AC | 28 ms
6,944 KB |
testcase_04 | AC | 29 ms
6,944 KB |
testcase_05 | AC | 3 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 25 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
ソースコード
#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)); bool res=true; int a[3]={}; for(auto& c: s) { if (c=='R') { ++a[0]; } if (c=='G') { if (!a[0]) { res=false; break; } else { --a[0]; ++a[1]; } } if (c=='W') { if (!a[1]) { if (!a[2]) { res=false; break; } } else { --a[1]; ++a[2]; } } } if (a[0] or a[1]) res=false; cout<<(res ? "possible" : "impossible")<<endl; } }