結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-06-19 15:51:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 583 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 56,028 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:31:36 |
合計ジャッジ時間 | 1,618 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 6 WA * 2 |
ソースコード
#include<iostream> #include<string> using namespace std; string solve(string str){ # define OK "possible" # define NG "impossible" int n = str.size(), w=0, g=0; if(str[n-1] != 'R') return NG; for(int i=0; i<n; ++i){ char c = str[i]; if(c == 'W') ++w; else if(c == 'G') ++g; else{ --w, --g; if(w<0 || g<0) return NG; } } if(g != 0) return NG; return OK; } int main(){ int n; cin >> n; for(int i=0; i<n; ++i){ string str; cin >> str; cout << solve(str) << endl; } }