結果
| 問題 |
No.154 市バス
|
| ユーザー |
sei0o
|
| 提出日時 | 2017-10-18 20:08:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,065 bytes |
| コンパイル時間 | 888 ms |
| コンパイル使用メモリ | 93,344 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 09:14:09 |
| 合計ジャッジ時間 | 1,600 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 7 WA * 1 |
ソースコード
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int main() {
int T;
cin >> T;
for (int i = 0; i < T; i++) {
string S;
cin >> S;
int w = 0, g = 0, r = 0;
bool possible = true;
for (int k = 0; k < S.length(); k++) {
switch (S[k]) {
case 'W':
w++;
break;
case 'G':
g++;
if (w < g) possible = false;
break;
case 'R':
r++;
if (w < r || g < r) possible = false;
break;
}
if (!possible) break;
}
if (((g == 0 || r == 0) && w > 0) || (g != r)) {
possible = false;
}
cout << (possible ? "possible" : "impossible") << endl;
}
return 0;
}
sei0o