結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-12 01:43:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 627 bytes |
| コンパイル時間 | 2,291 ms |
| コンパイル使用メモリ | 195,100 KB |
| 最終ジャッジ日時 | 2025-01-10 10:31:42 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 7 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:42:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
42 | int q; scanf("%d",&q); rep(_,q) solve();
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
void solve(){
string s; cin>>s;
while(!s.empty()){
int n=s.length();
if(s[n-1]!='R'){
puts("impossible");
return;
}
vector<bool> del(n);
del[n-1]=true;
int phase=0;
for(int i=n-2;i>=0;i--){
if(phase==0 && s[i]=='G'){
del[i]=true;
phase=1;
}
else if(phase==1 && s[i]=='W'){
del[i]=true;
}
}
if(phase==0){
puts("impossible");
return;
}
string t;
rep(i,n) if(!del[i]) t+=s[i];
s=t;
}
puts("possible");
}
int main(){
int q; scanf("%d",&q); rep(_,q) solve();
return 0;
}