結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
zakuro9715
|
| 提出日時 | 2016-06-19 23:43:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,030 bytes |
| コンパイル時間 | 458 ms |
| コンパイル使用メモリ | 55,520 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 08:33:25 |
| 合計ジャッジ時間 | 1,213 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 1 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
string s;
bool replace_before(char c, char c2, int n)
{
for(int i = n - 1; i >= 0; i--)
{
if (s[i] == c)
{
s[i] = '#';
return true;
}
}
return false;
}
int main()
{
int T;
cin >> T;
for(int t = 0; t < T; t++)
{
cin >> s;
if (s[s.length() - 1] != 'R')
{
cout << "impossible" << endl;
continue;
}
int w = 0, g = 0, r = 0;
bool ok = true;
bool extra_w = false;
for (int i = 0; i < s.length(); i++)
{
if (s[i] == 'W')
{
w++;
extra_w = true;
}
if (s[i] == 'G')
{
g++;
extra_w = false;
if (--w < 0)
{
ok = false;
break;
}
}
if (s[i] == 'R')
{
r++;
if (--g < 0)
{
ok = false;
break;
}
}
}
if (ok && !extra_w)
cout << "possible" << endl;
else
cout << "impossible" << endl;
}
}
zakuro9715