結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2015-04-03 00:45:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 560 ms |
コンパイル使用メモリ | 69,696 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 07:18:03 |
合計ジャッジ時間 | 1,516 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#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 (countR == 0 || countR != countG) { impossible(); return false; } if (indexW > indexG) { impossible(); return false; } possible(); return true; } int main(int argc, char **argv) { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; resolve(s); } return 0; }