結果

問題 No.452 横着者のビンゴゲーム
ユーザー hirokazu1020hirokazu1020
提出日時 2016-12-03 18:31:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 274 ms / 3,000 ms
コード長 1,075 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 11,016 KB
実行使用メモリ 17,096 KB
最終ジャッジ日時 2023-08-19 08:24:04
合計ジャッジ時間 5,321 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,244 KB
testcase_01 AC 16 ms
8,332 KB
testcase_02 AC 16 ms
7,876 KB
testcase_03 AC 19 ms
8,248 KB
testcase_04 AC 16 ms
8,408 KB
testcase_05 AC 20 ms
8,348 KB
testcase_06 AC 17 ms
8,244 KB
testcase_07 AC 17 ms
8,196 KB
testcase_08 AC 18 ms
8,252 KB
testcase_09 AC 16 ms
8,244 KB
testcase_10 AC 17 ms
8,228 KB
testcase_11 AC 18 ms
8,292 KB
testcase_12 AC 17 ms
8,348 KB
testcase_13 AC 15 ms
8,220 KB
testcase_14 AC 194 ms
17,096 KB
testcase_15 AC 190 ms
16,800 KB
testcase_16 AC 104 ms
12,712 KB
testcase_17 AC 24 ms
8,516 KB
testcase_18 AC 59 ms
9,264 KB
testcase_19 AC 38 ms
8,800 KB
testcase_20 AC 33 ms
8,512 KB
testcase_21 AC 103 ms
10,192 KB
testcase_22 AC 31 ms
8,604 KB
testcase_23 AC 155 ms
11,684 KB
testcase_24 AC 27 ms
8,400 KB
testcase_25 AC 26 ms
8,188 KB
testcase_26 AC 95 ms
10,268 KB
testcase_27 AC 60 ms
9,336 KB
testcase_28 AC 62 ms
9,312 KB
testcase_29 AC 41 ms
8,916 KB
testcase_30 AC 115 ms
10,608 KB
testcase_31 AC 38 ms
8,840 KB
testcase_32 AC 30 ms
8,592 KB
testcase_33 AC 54 ms
9,160 KB
testcase_34 AC 55 ms
9,216 KB
testcase_35 AC 42 ms
8,924 KB
testcase_36 AC 27 ms
8,272 KB
testcase_37 AC 26 ms
8,416 KB
testcase_38 AC 274 ms
13,968 KB
testcase_39 AC 182 ms
12,148 KB
testcase_40 AC 180 ms
12,132 KB
testcase_41 AC 178 ms
12,240 KB
testcase_42 AC 178 ms
12,196 KB
testcase_43 AC 182 ms
12,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int, input().split())
ans = 2*n-1
idx={}
val =[[] for j in range(m*(2*n+2))]
cnt = [0]*(m*(2*n+2))

for i in range(m):
    b = i*(2*n+2);
    for y in range(n):
        row = input().split()
        for x in range(n):
            c = int(row[x])
            if not c in idx:
                idx[c]=[]
            idx[c].append(b + y)
            val[b + y].append(c)
            idx[c].append(b + n + x)
            val[b + n + x].append(c)
            if y==x:
                idx[c].append(b+2*n)
                val[b+2*n].append(c)
            if n-1-y==x:
                idx[c].append(b+2*n+1)
                val[b+2*n+1].append(c)
for i in range(m):
    for j in range(2*n+2):
        for v in val[i*(2*n+2) + j]:
            for k in idx[v]:
                if not (i*(2*n+2) <= k and k < (i+1)*(2*n+2)):
                    cnt[k] += 1
                    ans = min(ans, 2*n-cnt[k]-1)
        for v in val[i*(2*n+2) + j]:
            for k in idx[v]:
                if not (i*(2*n+2) <= k and k < (i+1)*(2*n+2)):
                    cnt[k] -= 1
print(ans)
0