結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,168 KB
testcase_01 AC 130 ms
41,240 KB
testcase_02 AC 134 ms
41,292 KB
testcase_03 AC 175 ms
42,452 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 131 ms
41,300 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 133 ms
41,200 KB
testcase_10 WA -
testcase_11 AC 145 ms
41,840 KB
testcase_12 AC 138 ms
41,496 KB
testcase_13 AC 128 ms
41,208 KB
testcase_14 AC 842 ms
57,008 KB
testcase_15 AC 836 ms
57,120 KB
testcase_16 AC 475 ms
50,612 KB
testcase_17 AC 315 ms
47,620 KB
testcase_18 WA -
testcase_19 AC 326 ms
47,912 KB
testcase_20 AC 276 ms
47,116 KB
testcase_21 WA -
testcase_22 AC 298 ms
48,184 KB
testcase_23 AC 463 ms
49,692 KB
testcase_24 AC 288 ms
47,420 KB
testcase_25 AC 242 ms
47,808 KB
testcase_26 AC 395 ms
49,444 KB
testcase_27 AC 376 ms
48,812 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 403 ms
49,512 KB
testcase_31 AC 289 ms
48,096 KB
testcase_32 AC 255 ms
48,064 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 340 ms
48,168 KB
testcase_36 AC 263 ms
48,104 KB
testcase_37 AC 246 ms
47,128 KB
testcase_38 WA -
testcase_39 AC 524 ms
50,100 KB
testcase_40 AC 505 ms
50,184 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) {
				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 + 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, min);
					}
				}
			}
		}
		System.out.println(min - 1);
	}
}
0