結果
| 問題 |
No.154 市バス
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-06-14 23:20:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,048 bytes |
| コンパイル時間 | 464 ms |
| コンパイル使用メモリ | 59,304 KB |
| 最終ジャッジ日時 | 2024-11-14 19:45:18 |
| 合計ジャッジ時間 | 909 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:16:9: error: 'vector' was not declared in this scope
16 | vector<string> bus;
| ^~~~~~
main.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:16:22: error: expected primary-expression before '>' token
16 | vector<string> bus;
| ^
main.cpp:16:24: error: 'bus' was not declared in this scope
16 | vector<string> bus;
| ^~~
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int T; cin>>T;
while (T--) {
string s; cin>>s;
int n=s.size();
const string possible="possible";
const string impossible="impossible";
string res=possible;
vector<string> bus;
for(int i=n-1; i>=0; --i) {
char c=s[i];
if (c=='R') {
bus.push_back("R");
}
else if (c=='G') {
bool ok=false;
for(auto& b: bus) if (b.back()=='R') { b+=c; ok=true; break; }
if (!ok) res=impossible;
}
else {
bool ok=false;
for(auto& b: bus) if (b.back()=='G') { b+=c; ok=true; break; }
if (!ok) {
for(auto& b: bus) if (b.back()=='W') { ok=true; break; }
}
if (!ok) res=impossible;
}
}
for(auto& b: bus) if (b!="RGW") res=impossible;
cout<<res<<endl;
}
}
hogeover30