結果

問題 No.154 市バス
ユーザー nanTosaka2nanTosaka2
提出日時 2016-06-19 23:38:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 144,732 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 11:49:26
合計ジャッジ時間 2,103 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define REP(i, s, n) for(int i = (s); i < (n); i++)
#define all(co) begin(co), end(co)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))
using P = pair<int, int>;

signed main() {
	int x = 0;
	int n; cin >> n;
	rep(_, n) {
		string s; cin >> s;
		int w = 0, g = 0, r = 0;
		bool ok = true;
		bool wg = false;
		for (char c : s) {
			if (c == 'W') { w++; wg = true; }
			if (c == 'G') { g++; wg = false; }
			if (c == 'R') { r++;  }
			if (g > w || r > g) {
				ok == false;
				break;
			}
		}
		cout << (!wg && ok && g == r ? "possible" : "impossible") << endl;
	}
	//cin >> n;
}
0