結果

問題 No.154 市バス
ユーザー takana-sky07takana-sky07
提出日時 2019-07-29 20:13:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 786 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 68,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 11:59:29
合計ジャッジ時間 2,540 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/*
* 154_sample.cpp
* 
* No.154 soX
* Փx2.5
*/

#include <iostream>

// ֐
bool judge(const char* s) {
	// ꂼ̐F̃JEg
	int w = 0;
	int g = 0;
	int r = 0;
	// RȊO̍Ō̕ۑp
	char rr = '\0';
	for (int i=0; s[i]; i++) {
		if (s[i] == 'R') {
			r++;
		} else {
			// RȊO̕rrɈꎞۑĂ
			rr = s[i];
			s[i]=='G'? g++: w++;
		}
	}
	// RȊO̍Ō̕GłȂƂ
	if (rr != 'G' || g != r) {
		return false;
	}
	return true;
}

int main () {
	// W
	int n = 0;
	std::cin >> n;
	char s[1010]={};
	for (int i=0; i<n; i++) {
		std::cin >> s;
		
	// p^[蓾̂ł邩Ȃ
	std::cout << (judge(s) == true ? "possible" : "impossible") << std::endl;
	}
	
	return 0;
	
}
0