結果

問題 No.154 市バス
ユーザー kou6839kou6839
提出日時 2015-02-24 20:58:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 2,766 ms
コンパイル使用メモリ 73,820 KB
実行使用メモリ 58,812 KB
最終ジャッジ日時 2024-04-21 08:14:50
合計ジャッジ時間 6,114 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
権限があれば一括ダウンロードができます

ソースコード

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;
			for(int j=0;j<string.length();j++){
				if(string.charAt(i)=='G') gc++;
				if(string.charAt(i)=='R') rc++;
			}
			if(gc!=rc){
				System.out.println("impossible");
				continue;
			}
			if(string.lastIndexOf("R")<string.lastIndexOf("G")){
				System.out.println("impossible");
				continue;
			}
			System.out.println("possible");
			
		}
	}
}
0