結果

問題 No.154 市バス
ユーザー Mcpu3Mcpu3
提出日時 2018-12-05 21:29:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 63,616 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 20:42:23
合計ジャッジ時間 1,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int main() {
	bool tmp2;
	int T, tmp1, tmp3, j;
	string S;
	cin >> T;
	for (int i = 0; i < T; ++i) {
		cin >> S;
		tmp1 = 0;
		tmp2 = false;
		tmp3 = 0;
		for (j = 0; j < S.size(); ++j) {
			if (S[j] == 'W') {
				++tmp1;
				tmp2 = true;
			}
			else if (S[j] == 'G') {
				if (tmp1 == 0) break;
				--tmp1;
				tmp2 = false;
				++tmp3;
			}
			else {
				if (tmp3 == 0) break;
				--tmp3;
			}
		}
		if (j != S.size() || tmp2 || tmp3) cout << "impossible";
		else cout << "possible";
		cout << endl;
	}
}
0