結果

問題 No.24 数当てゲーム
ユーザー kenji_shioyakenji_shioya
提出日時 2017-01-08 23:59:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 1,217 bytes
コンパイル時間 3,616 ms
コンパイル使用メモリ 74,824 KB
実行使用メモリ 56,028 KB
最終ジャッジ日時 2023-08-22 21:17:42
合計ジャッジ時間 5,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,028 KB
testcase_01 AC 129 ms
55,460 KB
testcase_02 AC 132 ms
55,800 KB
testcase_03 AC 129 ms
55,864 KB
testcase_04 AC 128 ms
55,880 KB
testcase_05 AC 129 ms
55,596 KB
testcase_06 AC 127 ms
55,780 KB
testcase_07 AC 129 ms
56,004 KB
testcase_08 AC 127 ms
55,684 KB
testcase_09 AC 131 ms
55,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class NumGuess{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String[] nums = new String[10];
    for (int i = 0; i < 10; i++) {
      nums[i] = "none";
    }

    int s = sc.nextInt();

    for (int i = 0; i < s; i++) {
      int[] ansNums = new int[4];
      for (int j = 0; j < 4; j++) {
        ansNums[j] = sc.nextInt();
      }
      String ans = sc.next();
      Arrays.sort(ansNums);
      if (ans.equals("NO")) {
        for (int index : ansNums) {
          nums[index] = "false";
        }
      } else {
        for (int j = 0; j < 10; j++) {
          if (Arrays.binarySearch(ansNums, j) < 0) {
            nums[j] = "false";
          } else {
            if (!nums[j].equals("false")) {
              nums[j] = "true";
            }
          }
        }
      }
    }
    int ans = 0;
    int trueIndex = 0;
    int noneIndex = 0;
    for (int i = 0; i < 10; i++) {
      if (nums[i].equals("true")) {
        trueIndex = i;
      } else if (nums[i].equals("none")) {
        noneIndex = i;
      }
    }
    if (trueIndex == 0) {
      ans = noneIndex;
    } else {
      ans = trueIndex;
    }
    System.out.println(ans);
  }
}
0