結果
問題 | No.355 数当てゲーム(2) |
ユーザー | ぴろず |
提出日時 | 2016-04-01 23:56:02 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,281 bytes |
コンパイル時間 | 3,998 ms |
コンパイル使用メモリ | 75,856 KB |
実行使用メモリ | 74,400 KB |
平均クエリ数 | 15.90 |
最終ジャッジ日時 | 2023-09-23 09:57:05 |
合計ジャッジ時間 | 21,172 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 171 ms
71,540 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | RE | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 168 ms
72,156 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 171 ms
74,372 KB |
testcase_23 | WA | - |
testcase_24 | AC | 167 ms
68,824 KB |
testcase_25 | WA | - |
testcase_26 | AC | 174 ms
71,820 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 169 ms
72,528 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 168 ms
72,332 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 177 ms
71,760 KB |
testcase_39 | RE | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 173 ms
74,004 KB |
testcase_44 | WA | - |
testcase_45 | AC | 171 ms
73,752 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 173 ms
72,096 KB |
testcase_50 | RE | - |
testcase_51 | WA | - |
ソースコード
package no355; import java.util.Scanner; public class Main { static int[] query = new int[4]; static int hit = 0; static int blow = 0; static Scanner sc = new Scanner(System.in); public static void main(String[] args) { while(true) { for(int i=0;i<4;i++) { query[i] = (int) (Math.random() * 10); } if (!isValid()) continue; query(); if (hit == 0) break; } for(int i=0;i<4;i++) { query(); if (blow == 0) { for(int j=0;j<=9;j++) { query[i] = j; if (!isValid()) continue; query(); if (hit == i + 1) { break; } } }else{ for(int j=i+1;j<4;j++) { int t1 = query[i]; int t2 = query[j]; query[i] = t2; query[j] = t1; query(); if (hit == i + 1) { break; } query[i] = t1; query[j] = t2; } } } } public static boolean isValid() { boolean[] used = new boolean[10]; for(int i=0;i<4;i++) { int x = query[i]; if (used[x]) { return false; } used[x] = true; } return true; } public static void query() { StringBuilder sb = new StringBuilder(); for(int i=0;i<4;i++) { if (i > 0) sb.append(' '); sb.append(query[i]); } System.out.println(sb.toString()); hit = sc.nextInt(); blow = sc.nextInt(); } }