結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,244 KB
testcase_01 AC 131 ms
41,444 KB
testcase_02 AC 136 ms
41,368 KB
testcase_03 AC 167 ms
42,428 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 135 ms
41,252 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 133 ms
41,272 KB
testcase_10 WA -
testcase_11 AC 144 ms
41,632 KB
testcase_12 AC 138 ms
41,668 KB
testcase_13 AC 131 ms
40,996 KB
testcase_14 AC 856 ms
57,400 KB
testcase_15 AC 844 ms
56,984 KB
testcase_16 AC 497 ms
49,912 KB
testcase_17 AC 308 ms
48,084 KB
testcase_18 WA -
testcase_19 AC 345 ms
48,028 KB
testcase_20 AC 285 ms
47,932 KB
testcase_21 WA -
testcase_22 AC 263 ms
47,372 KB
testcase_23 AC 508 ms
49,520 KB
testcase_24 AC 285 ms
47,028 KB
testcase_25 AC 243 ms
48,436 KB
testcase_26 AC 402 ms
49,348 KB
testcase_27 AC 400 ms
48,312 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 411 ms
50,128 KB
testcase_31 AC 290 ms
48,148 KB
testcase_32 AC 257 ms
47,608 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 347 ms
48,232 KB
testcase_36 AC 263 ms
48,128 KB
testcase_37 AC 257 ms
48,264 KB
testcase_38 WA -
testcase_39 AC 513 ms
49,736 KB
testcase_40 AC 511 ms
49,704 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