結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
chakku
|
| 提出日時 | 2016-06-20 09:12:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 772 bytes |
| コンパイル時間 | 408 ms |
| コンパイル使用メモリ | 55,900 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 08:34:59 |
| 合計ジャッジ時間 | 1,125 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 7 WA * 1 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
void solve(){
string s;cin>>s;
int g=0,r=0,gr=0;
int N=s.size();
for(int i=0;i<N;i++){
if(s[i]=='G'){
g++;
gr++;
}
if(s[i]=='R'){
r++;
gr--;
}
if(gr<0){
cout << "impossible" <<endl;
return;
}
}
if(g!=r||g==0||r==0||s[N-1]!='R'){
cout << "impossible" <<endl;
return;
}
for(int i=N-1;i>=0;i--){
if(s[i]=='G') break;
if(s[i]=='W'){
cout << "impossible" << endl;
return;
}
}
cout << "possible" << endl;
}
int main(){
int T;
cin>>T;
for(int i=0;i<T;i++){
solve();
}
}
chakku