結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2016-06-12 00:52:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 524 bytes |
コンパイル時間 | 1,455 ms |
コンパイル使用メモリ | 167,772 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:27:36 |
合計ジャッジ時間 | 2,204 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int T; cin >> T; while(T--){ string S; cin >> S; vector<int> cnt(3); int N = S.size(); bool ok = true; for(int i=N-1;i>=0;--i){ if(S[i] == 'W'){ if(cnt[1]){ cnt[1]--; cnt[2]++; } else if(!cnt[2]) ok = false; } else if(S[i] == 'G'){ if(!cnt[0]) ok = false; else{ cnt[0]--; cnt[1]++; } } else{ cnt[0]++; } } ok = ok && !cnt[0] && !cnt[1]; cout << (ok?"possible":"impossible") << endl; } return 0; }