結果

問題 No.154 市バス
ユーザー not_522not_522
提出日時 2015-07-28 08:39:48
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 508 bytes
コンパイル時間 1,348 ms
コンパイル使用メモリ 159,288 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 07:33:44
合計ジャッジ時間 2,071 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int a = 0, b = 0, c = 0;
    bool p = true;
    for (char t : s) {
      if (t == 'W') ++a;
      if (t == 'G') {
        if (a > b) p = false;
        ++b;
      }
      if (t == 'R') ++c;
      if (b > c) p = false;
    }
    if (a < b || b != c || c == 0) p = false;
    cout << (p ? "possible" : "impossible") << endl;
  }
}
0