結果
問題 | No.452 横着者のビンゴゲーム |
ユーザー | rpy3cpp |
提出日時 | 2017-04-25 22:38:44 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 632 ms / 3,000 ms |
コード長 | 1,255 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,440 KB |
最終ジャッジ日時 | 2024-09-13 11:39:45 |
合計ジャッジ時間 | 9,106 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
10,880 KB |
testcase_01 | AC | 31 ms
10,880 KB |
testcase_02 | AC | 30 ms
10,880 KB |
testcase_03 | AC | 36 ms
10,880 KB |
testcase_04 | AC | 29 ms
10,752 KB |
testcase_05 | AC | 34 ms
10,880 KB |
testcase_06 | AC | 30 ms
10,880 KB |
testcase_07 | AC | 31 ms
10,880 KB |
testcase_08 | AC | 32 ms
10,880 KB |
testcase_09 | AC | 30 ms
10,752 KB |
testcase_10 | AC | 30 ms
10,752 KB |
testcase_11 | AC | 32 ms
10,880 KB |
testcase_12 | AC | 31 ms
10,880 KB |
testcase_13 | AC | 30 ms
10,752 KB |
testcase_14 | AC | 632 ms
13,440 KB |
testcase_15 | AC | 610 ms
13,312 KB |
testcase_16 | AC | 401 ms
12,160 KB |
testcase_17 | AC | 174 ms
11,008 KB |
testcase_18 | AC | 99 ms
11,264 KB |
testcase_19 | AC | 112 ms
10,880 KB |
testcase_20 | AC | 119 ms
10,880 KB |
testcase_21 | AC | 168 ms
11,648 KB |
testcase_22 | AC | 123 ms
11,008 KB |
testcase_23 | AC | 278 ms
12,032 KB |
testcase_24 | AC | 67 ms
11,008 KB |
testcase_25 | AC | 74 ms
10,880 KB |
testcase_26 | AC | 197 ms
11,520 KB |
testcase_27 | AC | 190 ms
11,264 KB |
testcase_28 | AC | 108 ms
11,264 KB |
testcase_29 | AC | 103 ms
11,008 KB |
testcase_30 | AC | 210 ms
11,776 KB |
testcase_31 | AC | 74 ms
10,880 KB |
testcase_32 | AC | 79 ms
11,008 KB |
testcase_33 | AC | 153 ms
11,008 KB |
testcase_34 | AC | 122 ms
11,136 KB |
testcase_35 | AC | 147 ms
11,008 KB |
testcase_36 | AC | 85 ms
10,880 KB |
testcase_37 | AC | 58 ms
11,008 KB |
testcase_38 | AC | 587 ms
12,800 KB |
testcase_39 | AC | 423 ms
12,160 KB |
testcase_40 | AC | 429 ms
12,288 KB |
testcase_41 | AC | 427 ms
12,288 KB |
testcase_42 | AC | 424 ms
12,160 KB |
testcase_43 | AC | 431 ms
12,032 KB |
ソースコード
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): mymax = max mylen = len maxC = mymax(mymax(mymax(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 = mylen([1 for ei in e if bits[ei]]) # counts = mysum([bits[ei] for ei in e]) if counts > record: record = counts for di in d: bits[di] = 0 if record == N: return N - 1 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))