結果

問題 No.24 数当てゲーム
ユーザー dazydazy
提出日時 2016-09-08 16:54:34
言語 Java19
(openjdk 21)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 1,386 bytes
コンパイル時間 5,076 ms
コンパイル使用メモリ 74,432 KB
実行使用メモリ 56,080 KB
最終ジャッジ日時 2023-08-09 23:52:25
合計ジャッジ時間 5,302 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
55,732 KB
testcase_01 AC 109 ms
56,080 KB
testcase_02 AC 111 ms
55,988 KB
testcase_03 AC 116 ms
55,868 KB
testcase_04 AC 108 ms
55,676 KB
testcase_05 AC 106 ms
56,044 KB
testcase_06 AC 104 ms
56,028 KB
testcase_07 AC 107 ms
55,720 KB
testcase_08 AC 104 ms
55,936 KB
testcase_09 AC 104 ms
56,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        if (N < 2||N > 6) System.exit(1);
        int A, B, C, D;
        String R;
        boolean[] ans = new boolean[10];
        for (int i = 0; i < 10; i++) {
            ans[i] = true;
        }
        for (int i = 0; i < N; i++) {
            A = scan.nextInt();
            B = scan.nextInt();
            C = scan.nextInt();
            D = scan.nextInt();
            R = scan.next();
            if (!match(A, B, C, D)||!(R.equals("YES")||R.equals("NO"))) System.exit(1);
            if (R.equals("YES")) {
                for (int j = 0; j < 10; j++) {
                    if (!eq(j,A,B,C,D)) ans[j] = false;
                }
            } else {
                ans[A] = ans[B] = ans[C] = ans[D] = false;
            }
        }

        for (int i = 0; i < 10; i++) {
            if (ans[i]) {
                System.out.println(i);
                break;
            }
        }
    }

    public static boolean match (int... args) {
        for (int i : args) {
            if (i < 0 || i > 9) return false;
        }
        return true;
    }

    public static boolean eq (int x, int... args) {
        for (int i : args) {
            if (i == x)  return true;
        }
        return false;
    }
}
0