結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-18 00:51:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 439 ms / 2,000 ms |
| コード長 | 885 bytes |
| コンパイル時間 | 747 ms |
| コンパイル使用メモリ | 63,448 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 06:41:51 |
| 合計ジャッジ時間 | 4,386 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main()
{
int T; cin>>T;
while (T--) {
string s; cin>>s;
int n=s.size();
multiset<int> v;
bool possible=true;
for(int i=n-1;i>=0;--i) {
if (s[i]=='R') {
v.insert(1);
}
if (s[i]=='G') {
if (v.empty() or *v.begin()!=1) { possible=false; break; }
v.erase(v.begin());
v.insert(2);
}
if (s[i]=='W') {
if (!v.count(2) and !v.count(3)) { possible=false; break; }
auto a=v.find(2), b=v.find(3);
v.erase(a!=v.end()?a:b);
v.insert(3);
}
}
for(int a: v) if (a!=3) { possible=false; break; }
cout<<(possible?"possible":"impossible")<<endl;
}
}
hogeover30