結果

問題 No.154 市バス
ユーザー kuuso1kuuso1
提出日時 2015-02-17 23:55:03
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,346 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 106,368 KB
実行使用メモリ 21,888 KB
最終ジャッジ日時 2024-04-21 07:46:02
合計ジャッジ時間 1,873 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
21,760 KB
testcase_01 AC 44 ms
21,632 KB
testcase_02 AC 43 ms
21,888 KB
testcase_03 AC 42 ms
21,760 KB
testcase_04 WA -
testcase_05 AC 22 ms
17,408 KB
testcase_06 AC 22 ms
17,792 KB
testcase_07 AC 38 ms
21,504 KB
testcase_08 AC 23 ms
17,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
			int g=0;
			int w=0;
			bool chk=true;
			bool wok=false;
			for(int i=S.Length-1;i>=0;i--){
				if(S[i]=='R'){
					r++;
					
					continue;
				}
				if(S[i]=='W'){
					if(r==0){chk=false;break;}
					if(g==0){chk=false;break;}
					if(!wok){chk=false;break;}
					w++;
					continue;
				}
				if(S[i]=='G'){
					g++;
					if(r>0)wok=true;
					if(g>r){chk=false;break;}
					continue;
				}
			}
			Console.WriteLine( (chk&(r==g)&(r+g+w>=3)&(w>=r))?"possible":"impossible");
		
		}
	}
	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