結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-09 10:34:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 834 bytes |
| コンパイル時間 | 513 ms |
| コンパイル使用メモリ | 65,808 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-23 04:18:12 |
| 合計ジャッジ時間 | 1,284 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 2 |
ソースコード
#include<iostream>
using namespace std;
int main(){
int t;
cin >> t;
string s;
for(int i = 0; i < t; i++){
cin >> s;
bool judge = true;
int tmp = 0, w = 0, bus = 0;
for(int i = 0; i < s.length(); i++){
if(s[i] == 'G'){
tmp++;
}else if(s[i] == 'R'){
tmp--;
bus++;
if(tmp < 0) judge = false;
}else if(s[i] == 'W'){
w++;
}
}
if(w < bus) judge = false;
if(s[s.length()-1] != 'R') judge = false;
for(int i = s.length()-1; i >= 0 && s[i] != 'G'; i--){
if(s[i] == 'W') judge = false;
}
if(judge) cout << "possible" << endl;
else cout << "impossible" << endl;
}
return 0;
}