結果
問題 | No.154 市バス |
ユーザー | takeya_okino |
提出日時 | 2019-08-02 22:37:24 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 821 bytes |
コンパイル時間 | 2,072 ms |
コンパイル使用メモリ | 73,964 KB |
実行使用メモリ | 62,384 KB |
最終ジャッジ日時 | 2023-09-18 18:29:42 |
合計ジャッジ時間 | 6,335 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 126 ms
55,572 KB |
testcase_06 | AC | 125 ms
55,956 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
ソースコード
import java.util.*; public 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 s = sc.next(); int len = s.length(); int[] w = new int[len]; int[] g = new int[len]; int[] r = new int[len]; int w1 = 0; int g1 = 0; int p = 0; for(int j = 0; j < len; j++) { if(s.charAt(j) == 'W') { w[j]++; w1 = j; } else if(s.charAt(j) == 'G') { g[j]++; g1 = j; } else { r[j]++; } if((w[j] < g[j]) || (g[j] < r[j])) p++; } String ans = "impossible"; if((p == 0) && (g[len - 1] == r[len - 1]) && (w1 < g1)) ans = "possible"; System.out.println(ans); } } }