結果

問題 No.452 横着者のビンゴゲーム
ユーザー rpy3cpprpy3cpp
提出日時 2017-04-25 22:29:12
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 724 ms / 3,000 ms
コード長 1,106 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 11,148 KB
最終ジャッジ日時 2023-10-11 10:10:53
合計ジャッジ時間 12,048 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,288 KB
testcase_01 AC 17 ms
8,264 KB
testcase_02 AC 17 ms
8,364 KB
testcase_03 AC 20 ms
8,316 KB
testcase_04 AC 17 ms
8,228 KB
testcase_05 AC 21 ms
8,332 KB
testcase_06 AC 16 ms
8,364 KB
testcase_07 AC 17 ms
8,408 KB
testcase_08 AC 18 ms
8,048 KB
testcase_09 AC 17 ms
8,240 KB
testcase_10 AC 17 ms
8,436 KB
testcase_11 AC 18 ms
8,452 KB
testcase_12 AC 17 ms
8,288 KB
testcase_13 AC 16 ms
8,364 KB
testcase_14 AC 724 ms
11,148 KB
testcase_15 AC 704 ms
11,032 KB
testcase_16 AC 477 ms
9,744 KB
testcase_17 AC 273 ms
8,496 KB
testcase_18 AC 102 ms
8,608 KB
testcase_19 AC 139 ms
8,440 KB
testcase_20 AC 158 ms
8,112 KB
testcase_21 AC 185 ms
9,144 KB
testcase_22 AC 171 ms
8,444 KB
testcase_23 AC 297 ms
9,468 KB
testcase_24 AC 184 ms
8,052 KB
testcase_25 AC 84 ms
8,332 KB
testcase_26 AC 222 ms
9,088 KB
testcase_27 AC 241 ms
8,684 KB
testcase_28 AC 111 ms
8,784 KB
testcase_29 AC 120 ms
8,484 KB
testcase_30 AC 236 ms
9,132 KB
testcase_31 AC 74 ms
8,572 KB
testcase_32 AC 91 ms
8,408 KB
testcase_33 AC 190 ms
8,712 KB
testcase_34 AC 140 ms
8,688 KB
testcase_35 AC 193 ms
8,436 KB
testcase_36 AC 102 ms
8,024 KB
testcase_37 AC 139 ms
8,164 KB
testcase_38 AC 653 ms
10,460 KB
testcase_39 AC 483 ms
9,548 KB
testcase_40 AC 484 ms
9,540 KB
testcase_41 AC 482 ms
9,664 KB
testcase_42 AC 484 ms
9,716 KB
testcase_43 AC 481 ms
9,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N, M = map(int, input().split())
    Cs = []
    for m in range(M):
        mat = [list(map(int, input().split())) for n in range(N)]
        Cs.append(mat)
    return N, M, Cs

def solve(N, M, Cs):
    maxC = max(max(max(c) for c in C) for C in Cs)
    Ds = C2D(N, M, Cs)
    record = 0
    bits = [0] * (maxC + 1)
    for i, D in enumerate(Ds):
        for d in D:
            for di in d:
                bits[di] = 1
            for E in Ds[i + 1:]:
                for e in E:
                    counts = len([1 for ei in e if bits[ei]])
                    if counts > record:
                        record = counts
            for di in d:
                bits[di] = 0
    return 2 * N - 1 - record

def C2D(N, M, Cs):
    return [c2d(N, C) for C in Cs]

def c2d(N, C):
    d = []
    for c in C: d.append(c[:])
    Ct = list(zip(*C))
    for ct in Ct: d.append(list(ct))
    diagonal1 = [C[i][i] for i in range(N)]
    d.append(diagonal1)
    diagonal2 = [C[N - 1 - i][i] for i in range(N)]
    d.append(diagonal2)
    return d

N, M, Cs = read_data()
print(solve(N, M, Cs))
0