結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
zakuro9715
|
| 提出日時 | 2016-06-19 23:40:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,075 bytes |
| コンパイル時間 | 427 ms |
| コンパイル使用メモリ | 55,776 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 08:33:15 |
| 合計ジャッジ時間 | 1,265 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
bool ok = true;
bool extra_w = false;
bool extra_g = false;
for (int i = 0; i < s.length(); i++)
{
if (s[i] == 'W')
extra_w = true;
if (s[i] == 'G')
{
extra_w = false;
extra_g = true;
if (!replace_before('W', 'w', i))
{
ok = false;
break;
}
}
if (s[i] == 'R')
{
extra_g = false;
if (!replace_before('G', 'g', i))
{
ok = false;
break;
}
}
}
if (ok && !extra_w && !extra_g)
cout << "possible" << endl;
else
cout << "impossible" << endl;
}
}
zakuro9715