結果

問題 No.154 市バス
ユーザー koba-e964koba-e964
提出日時 2015-06-06 17:40:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 81,244 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 08:35:29
合計ジャッジ時間 1,314 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

bool solve(const string &s) {
  int n = s.length();
  int w = 0, g = 0, r = 0;
  REP(i, 0, n) {
    switch(s[i]) {
    case 'W':
      w++;break;
    case 'G':
      g++; break;
    case 'R':
      r++;break;
    default:
      return 0;
    }
    if (w < g || w < r || g < r) {
      return 0;
    }
  }
  return g == r;
}

int main(void){
  int t;
  cin >> t;
  REP (loop_var, 0, t) {
    string s;
    cin >> s;
    cout << (solve(s) ? "possible" : "impossible") << endl;
  }
}
0