結果

問題 No.154 市バス
ユーザー troro_kelptroro_kelp
提出日時 2019-04-09 13:05:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,484 bytes
コンパイル時間 883 ms
コンパイル使用メモリ 98,856 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 15:50:13
合計ジャッジ時間 1,926 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,376 KB
testcase_01 AC 10 ms
4,376 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 8 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        string s;
        cin >> s;
        stack<char> st1, st2, st3;

        int n = s.size();
        bool f = true;
        for (int i = 0; i < n; ++i)
        {

            if (s[i] == 'G')
                st2.push(s[i]);

            if (s[i] == 'R')
            {
                if (st2.size() == 0)
                {
                    f = false;
                    break;
                }
                st2.pop();
            }
        }

        reverse(s.begin(), s.end());
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == 'R')
                break;
            if (s[i] == 'W' || s[i] == 'G')
            {
                f = false;
                break;
            }
        }

        if (st2.size() != 0)
            f = false;
        if (f)
            cout << "possible" << endl;
        else
            cout << "impossible" << endl;
    }
    return 0;
}
0