結果

問題 No.154 市バス
ユーザー Mcpu3
提出日時 2018-12-05 21:29:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 64,128 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 15:15:44
合計ジャッジ時間 1,579 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

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