結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2020-09-25 06:14:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 730 bytes |
コンパイル時間 | 2,331 ms |
コンパイル使用メモリ | 193,792 KB |
最終ジャッジ日時 | 2025-01-14 20:28:06 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 7 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) bool check(const string &s) { if (!count(s.begin(), s.end(), 'G')) return false; if (!count(s.begin(), s.end(), 'R')) return false; if (count(s.begin(), s.end(), 'W') && s.find_last_of("W") > s.find_last_of("G")) return false; int stk = 0; for (char c: s) { if (c == 'G') ++stk; else if (c == 'R') { if (--stk < 0) return false; } } return !stk; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while (T--) { string s; cin >> s; if (check(s)) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }