結果

問題 No.154 市バス
ユーザー ferinferin
提出日時 2017-03-03 01:20:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,017 bytes
コンパイル時間 1,376 ms
コンパイル使用メモリ 163,048 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 10:10:48
合計ジャッジ時間 2,103 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int t;
  string s[1010];
  cin >> t;
  REP(i, t) cin >> s[i];

  REP(i, t) {
    stack<char> a;
    while(a.size()) a.pop();
    bool flag = false;
    REP(j, s[i].size()) {
      if(s[i][j] == 'G') {
        a.push('G');
        flag = true;
      }
      else if(s[i][j] == 'R') {
        if(a.size() && a.top() == 'G') {
          a.pop();
        } else {
          a.push('a');
          break;
        }
      }
    }
    if(a.empty() && flag) {
      cout << "possible" << endl;
    } else {
      cout << "impossible" << endl;
    }
  }

  return 0;
}
0