結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-06-12 02:20:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 857 bytes |
| コンパイル時間 | 588 ms |
| コンパイル使用メモリ | 67,192 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 08:27:43 |
| 合計ジャッジ時間 | 1,354 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
int T; cin>>T;
while (T--) {
string s; cin>>s;
reverse(begin(s), end(s));
bool res=true;
int a[3]={};
for(auto& c: s) {
if (c=='R') {
++a[0];
}
if (c=='G') {
if (!a[0]) {
res=false; break;
}
else {
--a[0]; ++a[1];
}
}
if (c=='W') {
if (!a[1]) {
if (!a[2]) { res=false; break; }
}
else {
--a[1]; ++a[2];
}
}
}
if (a[0] or a[1]) res=false;
cout<<(res ? "possible" : "impossible")<<endl;
}
}
hogeover30