結果

問題 No.452 横着者のビンゴゲーム
ユーザー 37zigen37zigen
提出日時 2016-12-04 00:19:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,709 bytes
コンパイル時間 3,297 ms
コンパイル使用メモリ 79,964 KB
実行使用メモリ 56,816 KB
最終ジャッジ日時 2024-11-27 19:27:06
合計ジャッジ時間 17,213 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
40,360 KB
testcase_01 AC 108 ms
41,004 KB
testcase_02 AC 110 ms
41,036 KB
testcase_03 AC 148 ms
43,456 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 99 ms
39,868 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 110 ms
41,256 KB
testcase_10 WA -
testcase_11 AC 121 ms
41,608 KB
testcase_12 AC 115 ms
41,232 KB
testcase_13 AC 107 ms
40,844 KB
testcase_14 AC 752 ms
56,816 KB
testcase_15 AC 646 ms
50,364 KB
testcase_16 AC 483 ms
49,332 KB
testcase_17 AC 249 ms
48,320 KB
testcase_18 WA -
testcase_19 AC 295 ms
48,332 KB
testcase_20 AC 254 ms
48,140 KB
testcase_21 WA -
testcase_22 AC 217 ms
47,616 KB
testcase_23 AC 424 ms
50,696 KB
testcase_24 AC 226 ms
47,952 KB
testcase_25 AC 221 ms
47,796 KB
testcase_26 AC 346 ms
49,088 KB
testcase_27 AC 353 ms
48,872 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 389 ms
49,472 KB
testcase_31 AC 237 ms
47,844 KB
testcase_32 AC 231 ms
47,844 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 246 ms
47,908 KB
testcase_36 AC 223 ms
47,752 KB
testcase_37 AC 217 ms
47,716 KB
testcase_38 WA -
testcase_39 AC 502 ms
51,392 KB
testcase_40 AC 503 ms
50,324 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Q452 {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[][][] table = new int[m][n][n];
		for (int i = 0; i < m; ++i) {
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k < n; ++k) {
					table[i][j][k] = Integer.parseInt(sc.next()) - 1;
				}
			}
		}
		ArrayList[][] list = new ArrayList[m][2 * n + 2];
		for (int i = 0; i < list.length; ++i) {
			for (int j = 0; j < list[i].length; ++j) {
				list[i][j] = new ArrayList<>();
			}
		}

		for (int i = 0; i < m; ++i) {
			int p = 0;
			for (int j = 0; j < n; ++j) {
				ArrayList<Integer> set1 = new ArrayList<>();
				ArrayList<Integer> set2 = new ArrayList<>();
				for (int k = 0; k < n; ++k) {
					set1.add(table[i][j][k]);
					set2.add(table[i][k][j]);
					list[i][p].add(table[i][j][k]);
					list[i][p + 1].add(table[i][j][k]);
				}
				p += 2;
				list[i][2 * n].add(table[i][j][j]);
				list[i][2 * n + 1].add(table[i][n - 1 - j][j]);
			}
		}

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < m; ++i) {
			for (int j = i + 1; j < m; ++j) {
				for (ArrayList<Integer> list1 : list[i]) {
					boolean[] vis = new boolean[n * n * m];
					for (int set1 : list1) {
						vis[set1] = true;
					}
					for (ArrayList<Integer> list2 : list[j]) {
						int count = 0;
						for (int set2 : list2) {
							if (vis[set2]) {
								++count;
							}
						}
						min = Math.min(2 * n - count, min);
					}
				}
			}
		}
		System.out.println(min - 1);
	}
}
0