結果

問題 No.154 市バス
コンテスト
ユーザー kotatsugame
提出日時 2019-10-12 08:07:49
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 406 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 443 ms
コンパイル使用メモリ 74,752 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-21 14:22:30
合計ジャッジ時間 1,705 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 #
raw source code

#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