結果

問題 No.154 市バス
ユーザー kotatsugamekotatsugame
提出日時 2019-10-12 08:07:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 64,464 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 05:09:35
合計ジャッジ時間 1,562 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
4,380 KB
testcase_01 AC 25 ms
4,380 KB
testcase_02 AC 25 ms
4,376 KB
testcase_03 AC 25 ms
4,376 KB
testcase_04 AC 25 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 22 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
string s;
main()
{
	cin>>N;
	for(;N--;)
	{
		cin>>s;
		int X=0,Y=0,Z=0;
		bool flag=true;
		for(int i=s.size();i--;)
		{
			if(s[i]=='R')X++;
			else if(s[i]=='G')
			{
				if(X>0)X--,Y++;
				else flag=false;
			}
			else
			{
				if(Y>0)Y--,Z=1;
				else if(Z==0)flag=false;
			}
		}
		if(X>0||Y>0)flag=false;
		cout<<(flag?"":"im")<<"possible"<<endl;
	}
}
0