結果
問題 | No.154 市バス |
ユーザー | kroton |
提出日時 | 2016-06-19 22:54:55 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 498 bytes |
コンパイル時間 | 1,938 ms |
コンパイル使用メモリ | 159,464 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-21 09:43:38 |
合計ジャッジ時間 | 2,013 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; bool check(string S){ int w = 0, ws = 0, g = 0; for(char c : S){ if(c == 'W') ++w; if(c == 'G'){ if ((ws += w - 1) < 0) return false; ++g; } if(c == 'R' && --g < 0) return false; } return (w == 0 && g == 0); } int main(){ int T; cin >> T; for(int i=0;i<T;i++){ string S; cin >> S; cout << (check(S) ? "possible" : "impossible") << endl; } return 0; }