結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2017-10-18 21:17:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,133 bytes |
コンパイル時間 | 907 ms |
コンパイル使用メモリ | 91,812 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 09:14:34 |
合計ジャッジ時間 | 1,462 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <iostream> #include <queue> #include <vector> #include <cmath> #include <algorithm> #include <map> #include <iomanip> #include <numeric> using namespace std; using ll = long long; const ll INF = 1e9; const ll MOD = 1e9 + 7; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { string S; cin >> S; int w = 0, g = 0, r = 0, d = 0; bool possible = true; for (int k = 0; k < S.length(); k++) { switch (S[k]) { case 'W': w++; d++; break; case 'G': g++; d = 0; if (w < g) possible = false; break; case 'R': r++; if (w < r || g < r) possible = false; break; } if (!possible) break; } if (d > 0 || ((g == 0 || r == 0) && w > 0) || (g != r)) { possible = false; } cout << (possible ? "possible" : "impossible") << endl; } return 0; }