結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
40,192 KB
testcase_01 AC 116 ms
40,888 KB
testcase_02 AC 117 ms
40,964 KB
testcase_03 AC 151 ms
41,908 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 123 ms
41,100 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 106 ms
39,828 KB
testcase_10 WA -
testcase_11 AC 125 ms
41,420 KB
testcase_12 AC 125 ms
41,432 KB
testcase_13 AC 111 ms
40,824 KB
testcase_14 AC 697 ms
50,116 KB
testcase_15 AC 768 ms
56,704 KB
testcase_16 AC 450 ms
50,140 KB
testcase_17 AC 270 ms
46,980 KB
testcase_18 WA -
testcase_19 AC 306 ms
47,524 KB
testcase_20 AC 259 ms
47,152 KB
testcase_21 WA -
testcase_22 AC 236 ms
47,004 KB
testcase_23 AC 452 ms
49,104 KB
testcase_24 AC 230 ms
46,940 KB
testcase_25 AC 210 ms
47,008 KB
testcase_26 AC 364 ms
48,884 KB
testcase_27 AC 361 ms
48,156 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 381 ms
49,632 KB
testcase_31 AC 241 ms
47,596 KB
testcase_32 AC 232 ms
47,540 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 303 ms
48,092 KB
testcase_36 AC 227 ms
47,584 KB
testcase_37 AC 252 ms
46,964 KB
testcase_38 WA -
testcase_39 AC 497 ms
49,192 KB
testcase_40 AC 472 ms
49,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());
				}
			}
		}
		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) {
				for (int k = 0; k < n; ++k) {
					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 + 1];
					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 - 1, min);
					}
				}
			}
		}
		System.out.println(min);
	}
}
0