結果

問題 No.154 市バス
ユーザー kotatsugame
提出日時 2019-10-12 08:07:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 64,768 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 07:57:04
合計ジャッジ時間 1,749 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-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