結果

問題 No.154 市バス
ユーザー htensaihtensai
提出日時 2019-12-26 13:13:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 946 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 74,556 KB
実行使用メモリ 59,492 KB
最終ジャッジ日時 2024-04-14 11:48:58
合計ジャッジ時間 6,016 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 345 ms
58,836 KB
testcase_01 AC 350 ms
58,592 KB
testcase_02 AC 360 ms
58,720 KB
testcase_03 AC 342 ms
59,492 KB
testcase_04 WA -
testcase_05 AC 130 ms
53,964 KB
testcase_06 AC 130 ms
54,392 KB
testcase_07 AC 368 ms
58,912 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char[] arr = sc.next().toCharArray();
            int count = 0;
            int wcount = 0;
            for (char c : arr) {
                if (c == 'G') {
                    count++;
                    wcount = 0;
                } else if(c == 'R') {
                    count--;
                } else {
                    wcount++;
                }
                if (count < 0) {
                    break;
                }
            }
            if (count == 0 && wcount == 0) {
                sb.append("possible");
           } else {
                sb.append("impossible");
             }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}
0