結果
| 問題 | No.154 市バス |
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-02-18 00:04:42 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 952 bytes |
| 記録 | |
| コンパイル時間 | 840 ms |
| コンパイル使用メモリ | 106,408 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-30 15:00:26 |
| 合計ジャッジ時間 | 1,889 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 7 WA * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
void solve(){
char c[2000];
scanf("%s", c);
string s = c;
deque<int> w;
deque<int> g;
deque<int> r;
int n = s.size();
for(int i=0; i<n; i++){
if(s[i] == 'W'){
w.push_back(i);
}else if(s[i] == 'G'){
if(w.size() > 0){
w.pop_front();
g.push_back(i);
}else{
cout << "impossible" << endl;
return;
}
}else if(s[i] == 'R'){
if(g.size() > 0){
g.pop_front();
r.push_back(i);
}else{
cout << "impossible" << endl;
return;
}
}
}
if(g.size()>0 || r.size()==0){
cout << "impossible" << endl;
}else if(w.size()>0 && r.size()>0 && w.back() > r.back()){
cout << "impossible" << endl;
}else{
cout << "possible" << endl;
}
}
int main(){
int T;
cin >> T;
while(T--){
solve();
}
}
koyumeishi