結果

問題 No.452 横着者のビンゴゲーム
ユーザー maspymaspy
提出日時 2020-03-19 13:04:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 83,380 KB
最終ジャッジ日時 2023-08-20 20:46:35
合計ジャッジ時間 6,145 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,488 KB
testcase_01 AC 74 ms
71,124 KB
testcase_02 AC 74 ms
71,532 KB
testcase_03 WA -
testcase_04 AC 75 ms
71,268 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 73 ms
71,076 KB
testcase_09 WA -
testcase_10 AC 74 ms
71,408 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 76 ms
71,480 KB
testcase_14 AC 151 ms
83,380 KB
testcase_15 AC 148 ms
82,976 KB
testcase_16 AC 99 ms
77,940 KB
testcase_17 AC 121 ms
76,208 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 93 ms
76,836 KB
testcase_22 WA -
testcase_23 AC 108 ms
78,656 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 91 ms
76,624 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools

N, M = map(int, readline().split())
C = tuple(map(int, read().split()))


def get_bingos(n):
    n *= N * N
    for i in range(N):
        yield frozenset(C[n + N * i + j] for j in range(N))
        yield frozenset(C[n + N * j + i] for j in range(N))
    yield frozenset(C[n + N * j + j] for j in range(N))
    yield frozenset(C[n + N * (N - 1 - j) + j] for j in range(N))


bingos = tuple(get_bingos(i) for i in range(M))


def solve_two_card(i, j):
    best = 0
    for S1, S2 in itertools.product(bingos[i], bingos[j]):
        common = len(S1 & S2)
        if best < common:
            best = common
    return N + N - best - 1


answer = min(solve_two_card(i, j) for i, j in itertools.combinations(range(M), 2))
print(answer)
0