結果

問題 No.154 市バス
ユーザー しらっ亭しらっ亭
提出日時 2016-06-12 21:48:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,006 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 169,452 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:35:47
合計ジャッジ時間 2,635 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
6,812 KB
testcase_01 AC 27 ms
6,944 KB
testcase_02 AC 26 ms
6,944 KB
testcase_03 AC 20 ms
6,944 KB
testcase_04 AC 25 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 21 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
typedef long long ll;
// -------------------------------------

void Main() {
  string s;
  cin >> s;
  map<char, int> co;
  bool ok = 1;
  int lw=-1,lg=-1;
  rep(i, 0, SZ(s)) {
    char c = s[i];
    co[c]++;
    if (co['W'] < co['G'] || co['G'] < co['R']) {
      ok = 0;
      break;
    }
    if (c == 'G') lg = i;
    if (c == 'W') lw = i;
  }

  if (co['G'] != co['R']) {
    ok = 0;
  }
  if (lg < lw) ok = 0;

  puts(ok ? "possible" : "impossible");
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) Main();
  return 0;
}
0