結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2018-02-11 18:57:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 583 bytes |
コンパイル時間 | 1,016 ms |
コンパイル使用メモリ | 70,260 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 11:41:45 |
合計ジャッジ時間 | 2,078 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; bool solve(string s) { const int n = s.size(); int W = 0; int WW = 0; int G = 0; for (int i = 0; i < n; i++) { if (s[i] == 'W') { W++; WW++; } else if (s[i] == 'G') { WW = 0; W--; G++; } else { G--; } if (W < 0 || G < 0) return false; } return G == 0 && WW == 0; } int main() { int T; cin >> T; while (T--) { string s; cin >> s; cout << (solve(s) ? "possible" : "impossible") << endl; } }