結果

問題 No.154 市バス
ユーザー airuaiairuai
提出日時 2017-02-05 21:55:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 60,900 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 10:10:19
合計ジャッジ時間 1,250 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#define rep(n) for(int i = 0; i < n; ++i)
using namespace std;
int main(void) {
	int t;
	cin >> t;
	rep(t) {
		int c = 0, log = 0, count = 0;
		bool flag = true;
		string str;
		cin >> str;
		if (str[str.size() - 1] == 'W') { 
			cout << "impossible" << endl;
			break;
		}
		if(str.size())
		rep(str.size()) {
			if (str[i] == 'G') {
				++c, ++count;
				if (!log && i != str.size() - 1) {
					if (str[i + 1] == 'W') {
						log = 1;
					}
					else {
						log = 2;
					}
				}
			}
			else if (str[i] == 'R') {
				--c;
			}
			if (c < 0) {
				flag = false;
				break;
			}
		}
		if (count == 1 && log == 1) {
			flag = false;
		}
		if (flag) {
			if (c == 0) {
				cout << "possible" << endl;
			}
			else {
				cout << "impossible" << endl;
			}
		}
		else {
			cout << "impossible" << endl;
		}
	}
}
0