結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
eithia
|
| 提出日時 | 2015-02-18 03:44:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 782 bytes |
| コンパイル時間 | 1,213 ms |
| コンパイル使用メモリ | 159,728 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 06:46:45 |
| 合計ジャッジ時間 | 1,781 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
bool solve()
{
string s;
cin >> s;
int w = 0, g = 0;
for (char c : s) {
if (c == 'W') {
w = 1;
} else if (c == 'G') {
if (w == 0) return false;
w = 0, ++g;
} else if (c == 'R') {
if (g == 0) return false;
--g;
}
}
return w == 0 and g == 0;
}
int main()
{
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int t;
for (cin >> t; t--; ) {
cout << (solve() ? "possible" : "impossible") << endl;
}
}
eithia