結果

問題 No.154 市バス
ユーザー kou6839kou6839
提出日時 2015-02-24 21:07:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 943 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 77,492 KB
実行使用メモリ 58,840 KB
最終ジャッジ日時 2024-04-21 08:15:26
合計ジャッジ時間 6,856 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 448 ms
57,860 KB
testcase_01 AC 477 ms
57,708 KB
testcase_02 AC 479 ms
57,692 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 158 ms
53,932 KB
testcase_06 AC 158 ms
54,048 KB
testcase_07 AC 451 ms
57,312 KB
testcase_08 AC 158 ms
53,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int i=0;i<t;i++){
			String string = sc.next();
			int gc=0;
			int rc=0;
			int wc=0;
			for(int j=0;j<string.length();j++){
				if(string.charAt(j)=='G') gc++;
				if(string.charAt(j)=='R') rc++;
				if(string.charAt(j)=='W') wc++;
			}
			if(gc==0||rc==0||wc==0){
				System.out.println("impossible");
				continue;
			}
			if(gc!=rc){
				System.out.println("impossible");
				continue;
			}
			if(string.lastIndexOf("R")<string.lastIndexOf("G")){
				System.out.println("impossible");
				continue;
			}
			if(string.lastIndexOf("G")<string.lastIndexOf("W")){
				System.out.println("impossible");
				continue;
			}
			if(string.indexOf("R")<string.indexOf("G")){
				System.out.println("impossible");
				continue;
			}
			
			System.out.println("possible");
			
		}
	}
}
0