結果
| 問題 |
No.452 横着者のビンゴゲーム
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-19 13:04:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 888 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 82,588 KB |
| 実行使用メモリ | 82,004 KB |
| 最終ジャッジ日時 | 2024-12-14 03:07:34 |
| 合計ジャッジ時間 | 4,254 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 30 |
ソースコード
#!/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)
maspy