結果

問題 No.154 市バス
ユーザー ScottShelbyScottShelby
提出日時 2020-09-13 21:10:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 1,756 ms
コンパイル使用メモリ 168,260 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-13 04:31:17
合計ジャッジ時間 2,708 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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[0] < 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