結果
| 問題 |
No.154 市バス
|
| ユーザー |
ebicochineal
|
| 提出日時 | 2016-06-20 19:29:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 961 bytes |
| コンパイル時間 | 538 ms |
| コンパイル使用メモリ | 65,404 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 08:35:16 |
| 合計ジャッジ時間 | 1,297 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include <string>
#include <iostream>
using namespace std;
int main() {
string s;
cin >> s;
while ( cin >> s ) {
int w = 0, g = 0, r = 0, l = 0;
for ( char i : s ) { l += i == 'R' ? 1 : 0; }
int f = s[0] != 'W' ? 1 : 0;
for ( char i : s ) {
if ( i == 'W' ) {
w += 1;
if ( l == 0 ) {
f = 1;
}
}
if ( i == 'G' ) {
if ( l > 0 && w > 0 ) {
w -= 1; l -= 1; g += 1;
} else {
f = 1;
}
}
if ( i == 'R' ) {
if ( g > 0 ) {
g -= 1; r += 1;
} else {
f = 1;
}
}
if ( f ) { break; }
}
string o = !f && g == 0 ? "possible" : "impossible";
cout << o << endl;
}
return 0;
}
ebicochineal