結果

問題 No.154 市バス
ユーザー ScottShelbyScottShelby
提出日時 2020-09-13 21:07:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 165,708 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 23:58:16
合計ジャッジ時間 2,774 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

void solve() {
  string s;
  cin >> s;
  int n = s.length();
  vector<int> cnt(3);
  // reverse(s.begin(), s.end());
  bool ok = true;
  rep(i, n) {
    if (s[i] == 'W') cnt[0]++;
    if (s[i] == 'G') {
      cnt[1]++;
      cnt[0]--;
      if (cnt[1] < 0) ok = false;
    }
    if (s[i] == 'R') {
      cnt[2]++;
      cnt[1]--;
      if (cnt[1] < 0) ok = false;
    }
  }
  if (cnt[1] != 0) ok = false;

  string ans = "possible";
  if (!ok) ans = "impossible";
  cout << ans << endl;

}

int main() {
  int test;
  cin >> test;
  rep(i, test) solve();
}
0