結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2015-04-01 01:45:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 958 bytes |
コンパイル時間 | 549 ms |
コンパイル使用メモリ | 69,672 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 07:17:43 |
合計ジャッジ時間 | 1,256 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 7 WA * 1 |
ソースコード
#include <fstream> #include <cstdint> #include <iostream> #include <string> #include <vector> #include <list> #include <set> #include <map> #include <algorithm> using namespace std; void possible() { cout << "possible" << endl; } void impossible() { cout << "impossible" << endl; } bool resolve(const string& s) { int indexR = -1; int indexG = -1; int indexW = -1; int countR = 0; int countG = 0; int countW = 0; for (string::size_type i = 0; i < s.length(); i++) { char ch = s[i]; switch (ch) { case 'R': countR++; indexR = i; break; case 'G': countG++; indexG = i; break; case 'W': countW++; indexW = i; break; } if (countR > countG || countG > countW) { impossible(); return false; } } if (indexW > indexG) { impossible(); return false; } possible(); return true; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; resolve(s); } return 0; }