結果

問題 No.154 市バス
ユーザー hogeover30hogeover30
提出日時 2016-06-12 01:42:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 962 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 58,940 KB
最終ジャッジ日時 2024-04-27 02:21:02
合計ジャッジ時間 738 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:14:9: error: 'vector' was not declared in this scope
   14 |         vector<int> a;
      |         ^~~~~~
main.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | #include <string>
main.cpp:14:16: error: expected primary-expression before 'int'
   14 |         vector<int> a;
      |                ^~~
main.cpp:17:17: error: 'a' was not declared in this scope
   17 |                 a.push_back(0);
      |                 ^
main.cpp:20:35: error: 'a' was not declared in this scope
   20 |                 auto t=find(begin(a), end(a), 0);
      |                                   ^
main.cpp:28:35: error: 'a' was not declared in this scope
   28 |                 auto t=find(begin(a), end(a), 1);
      |                                   ^
main.cpp:36:25: error: 'a' was not declared in this scope
   36 |         if (count(begin(a), end(a), 2)!=a.size()) res=false;
      |                         ^

ソースコード

diff #

#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;
        vector<int> a;
        for(auto& c: s) {
            if (c=='R') {
                a.push_back(0);
            }
            else if (c=='G') {
                auto t=find(begin(a), end(a), 0);
                if (t==end(a)) {
                    res=false;
                    break;
                }
                *t=1;
            }
            else if (c=='W') {
                auto t=find(begin(a), end(a), 1);
                if (t==end(a) and find(begin(a), end(a), 2)==end(a)) {
                    res=false;
                    break;
                }
                *t=2;
            }
        }
        if (count(begin(a), end(a), 2)!=a.size()) res=false;

        cout<<(res ? "possible" : "impossible")<<endl;
    }
}
0