結果

問題 No.355 数当てゲーム(2)
ユーザー TatsuDXTatsuDX
提出日時 2016-10-16 20:52:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 3,084 bytes
コンパイル時間 3,261 ms
コンパイル使用メモリ 77,472 KB
実行使用メモリ 74,788 KB
平均クエリ数 23.35
最終ジャッジ日時 2023-09-24 00:37:42
合計ジャッジ時間 17,180 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 182 ms
72,864 KB
testcase_01 AC 192 ms
73,132 KB
testcase_02 AC 184 ms
71,072 KB
testcase_03 AC 204 ms
72,976 KB
testcase_04 AC 187 ms
73,492 KB
testcase_05 AC 183 ms
72,896 KB
testcase_06 AC 204 ms
73,404 KB
testcase_07 AC 191 ms
72,680 KB
testcase_08 AC 191 ms
73,016 KB
testcase_09 AC 191 ms
72,968 KB
testcase_10 AC 192 ms
73,228 KB
testcase_11 AC 195 ms
73,220 KB
testcase_12 AC 197 ms
73,460 KB
testcase_13 AC 176 ms
72,820 KB
testcase_14 AC 176 ms
74,788 KB
testcase_15 AC 178 ms
73,504 KB
testcase_16 AC 173 ms
73,020 KB
testcase_17 AC 198 ms
72,820 KB
testcase_18 AC 181 ms
72,876 KB
testcase_19 AC 200 ms
72,896 KB
testcase_20 AC 201 ms
70,900 KB
testcase_21 AC 203 ms
73,040 KB
testcase_22 AC 201 ms
72,824 KB
testcase_23 AC 187 ms
72,388 KB
testcase_24 AC 210 ms
72,768 KB
testcase_25 AC 199 ms
70,932 KB
testcase_26 AC 217 ms
70,452 KB
testcase_27 AC 187 ms
72,836 KB
testcase_28 AC 194 ms
72,732 KB
testcase_29 AC 190 ms
72,752 KB
testcase_30 AC 191 ms
73,456 KB
testcase_31 AC 195 ms
72,660 KB
testcase_32 AC 194 ms
72,608 KB
testcase_33 AC 203 ms
72,572 KB
testcase_34 AC 204 ms
73,596 KB
testcase_35 AC 177 ms
73,364 KB
testcase_36 AC 183 ms
72,732 KB
testcase_37 AC 202 ms
72,788 KB
testcase_38 AC 182 ms
72,624 KB
testcase_39 AC 204 ms
72,860 KB
testcase_40 AC 191 ms
72,600 KB
testcase_41 AC 200 ms
70,856 KB
testcase_42 AC 170 ms
72,640 KB
testcase_43 AC 182 ms
72,884 KB
testcase_44 AC 189 ms
73,036 KB
testcase_45 AC 204 ms
73,112 KB
testcase_46 AC 179 ms
72,692 KB
testcase_47 AC 192 ms
73,260 KB
testcase_48 AC 201 ms
73,032 KB
testcase_49 AC 179 ms
72,972 KB
testcase_50 AC 190 ms
73,148 KB
testcase_51 AC 179 ms
72,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Test {
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int idx = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i == j)
					continue;
				for (int k = 0; k < 4; k++) {
					if (i == k)
						continue;
					if (j == k)
						continue;
					for (int l = 0; l < 4; l++) {
						if (i == l)
							continue;
						if (j == l)
							continue;
						if (k == l)
							continue;
						p[idx][0] = i;
						p[idx][1] = j;
						p[idx][2] = k;
						p[idx][3] = l;
						idx++;
					}
				}
			}
		}
		chk();
	}

	public static int[] b = new int[4];
	public static int[] c = new int[4];
	public static boolean[] t = new boolean[10];
	public static int[][] p = new int[24][4];

	public static void chk() {
		int hit, blw;
		for (b[0] = 0; b[0] < 7; b[0]++) {
			for (b[1] = b[0] + 1; b[1] < 8; b[1]++) {
				for (b[2] = b[1] + 1; b[2] < 9; b[2]++) {
					for (b[3] = b[2] + 1; b[3] < 10; b[3]++) {
						System.out.println(b[0] +" "+ b[1] +" "+ b[2] +" "+ b[3]);
						hit = sc.nextInt();
						blw = sc.nextInt();
						if (hit == 4) {
							return;
						} else if (hit + blw == 4) {
							chk4();
							return;
						} else if (hit + blw == 3) {
							Arrays.fill(t, false);
							chk3();
							return;
						} else if (hit + blw == 0) {
							Arrays.fill(t, false);
							chk0();
							return;
						}
					}
				}
			}
		}
	}

	public static void chk0() {
		int hit, blw;
		for (int i = 0; i < 4; i++) {
			c[i] = b[i];
			t[b[i]] = true;
		}
		for (b[0] = c[0] + 1; b[0] < 7; b[0]++) {
			if (t[b[0]])
				continue;
			for (b[1] = b[0] + 1; b[1] < 8; b[1]++) {
				if (t[b[1]])
					continue;
				for (b[2] = b[1] + 1; b[2] < 9; b[2]++) {
					if (t[b[2]])
						continue;
					for (b[3] = b[2] + 1; b[3] < 10; b[3]++) {
						if (t[b[3]])
							continue;
						System.out.println(b[0] +" "+ b[1] +" "+ b[2] +" "+ b[3]);
						hit = sc.nextInt();
						blw = sc.nextInt();
						if (hit == 4) {
							return;
						} else if (hit + blw == 4) {
							chk4();
							return;
						} else if (hit + blw == 3) {
							chk3();
							return;
						}
					}
				}
			}
		}
	}

	public static void chk3() {
		int hit, blw;
		for (int i = 0; i < 4; i++) {
			c[i] = b[i];
			t[c[i]] = true;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = c[i] + 1; j < 10; j++) {
				if (t[j])
					continue;
				b[i] = j;
				System.out.println(b[0] +" "+ b[1] +" "+ b[2] +" "+ b[3]);
				hit = sc.nextInt();
				blw = sc.nextInt();
				if (hit == 4) {
					return;
				} else if (hit + blw == 4) {
					chk4();
					return;
				} else if (hit + blw == 2) {
					break;
				}
			}
			b[i] = c[i];
		}
	}

	public static void chk4() {
		int hit, blw;
		for (int i = 0; i < 4; i++) {
			c[i] = b[i];
		}
		for (int i = 1; i < 24; i++) {
			for (int j = 0; j < 4; j++) {
				b[j] = c[p[i][j]];
			}
			System.out.println(b[0] +" "+ b[1] +" "+ b[2] +" "+ b[3]);
			hit = sc.nextInt();
			blw = sc.nextInt();
			if (hit == 4) {
				return;
			}
		}
	}
}
0