結果

問題 No.154 市バス
ユーザー kuuso1kuuso1
提出日時 2015-02-18 00:26:46
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,436 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 112,796 KB
実行使用メモリ 29,956 KB
最終ジャッジ日時 2024-04-21 07:52:53
合計ジャッジ時間 2,029 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 23 ms
17,920 KB
testcase_06 AC 23 ms
17,792 KB
testcase_07 AC 42 ms
22,016 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		for(;T>0;T--){
			String S=rs();
			int r=0;
			bool chk=true;
			for(int i=S.Length-1;i>=0;i--){
				if(S[i]=='R'){
					r++;
				}
				if(S[i]=='G'){
					r--;
					if(r<0){chk=false;break;}
				}
			}
			if(!chk){Console.WriteLine("impossible");continue;}

			chk=true;
			int gr=0;
			bool chk2=false;
			for(int i=S.Length-1;i>=0;i--){
				if(S[i]=='R'){
					continue;
				}
				if(S[i]=='G'){
					gr++;chk2=true;
				}
				if(S[i]=='W'){
					if(gr==0){chk=false;break;}
					if(gr>0)gr--;
					chk2=false;
				}
			}
			if(!chk || chk2){Console.WriteLine("impossible");continue;}
			Console.WriteLine("possible");
		}
	}
	int T;
	public Sol(){
		T=ri();
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0