結果
問題 | No.1345 Beautiful BINGO |
ユーザー | tktk_snsn |
提出日時 | 2021-01-16 13:40:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,472 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 82,308 KB |
実行使用メモリ | 77,452 KB |
最終ジャッジ日時 | 2024-05-05 15:41:04 |
合計ジャッジ時間 | 15,136 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,096 KB |
testcase_01 | AC | 38 ms
52,864 KB |
testcase_02 | AC | 37 ms
52,736 KB |
testcase_03 | AC | 39 ms
52,480 KB |
testcase_04 | AC | 37 ms
52,096 KB |
testcase_05 | WA | - |
testcase_06 | AC | 36 ms
52,436 KB |
testcase_07 | WA | - |
testcase_08 | AC | 36 ms
52,352 KB |
testcase_09 | AC | 39 ms
52,096 KB |
testcase_10 | WA | - |
testcase_11 | AC | 44 ms
60,416 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 38 ms
52,480 KB |
testcase_15 | AC | 41 ms
52,080 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 39 ms
52,812 KB |
testcase_20 | AC | 38 ms
52,224 KB |
testcase_21 | AC | 38 ms
52,096 KB |
testcase_22 | AC | 43 ms
58,880 KB |
testcase_23 | AC | 45 ms
59,264 KB |
testcase_24 | AC | 79 ms
74,856 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 77 ms
74,488 KB |
testcase_29 | WA | - |
testcase_30 | AC | 53 ms
63,616 KB |
testcase_31 | AC | 93 ms
76,800 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 53 ms
63,232 KB |
testcase_35 | AC | 60 ms
67,072 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 37 ms
52,492 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 38 ms
52,736 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 36 ms
52,224 KB |
testcase_49 | AC | 37 ms
52,608 KB |
testcase_50 | AC | 36 ms
52,352 KB |
testcase_51 | AC | 35 ms
52,612 KB |
testcase_52 | AC | 760 ms
76,672 KB |
testcase_53 | WA | - |
testcase_54 | AC | 160 ms
76,928 KB |
testcase_55 | WA | - |
testcase_56 | AC | 761 ms
76,472 KB |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 762 ms
76,420 KB |
ソースコード
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) def pop_count(T): T = (T & 0x55555555) + ((T >> 1) & 0x55555555) T = (T & 0x33333333) + ((T >> 2) & 0x33333333) T = (T & 0x0F0F0F0F) + ((T >> 4) & 0x0F0F0F0F) T = (T & 0x00FF00FF) + ((T >> 8) & 0x00FF00FF) T = (T & 0x0000FFFF) + ((T >> 16) & 0x0000FFFF) return T N, M = map(int, input().split()) A = tuple(tuple(map(int, input().split())) for _ in range(N)) row = [sum(a) for a in A] col = [sum(a) for a in zip(*A)] # row += [sum(A[i][i] for i in range(N))] # row += [sum(A[N-i-1][i] for i in range(N))] ans = 10**18 n = N + 2 for S in range(1 << n): p = pop_count(S) if N + p < M: continue tmp = 0 coltmp = col[:] for i in range(N): if (S >> i) & 1: tmp += row[i] for j in range(N): coltmp[j] -= A[i][j] if (S >> N) & 1: for i in range(N): if (S >> i) & 1: continue tmp += A[i][i] coltmp[i] -= A[i][i] if (S >> (N + 1)) & 1: for i in range(N): if (S >> i) & 1: continue tmp += A[i][N-i-1] coltmp[i] -= A[i][N-i-1] if N % 2 == 1: m = N // 2 if ~(S >> m) & 1 and (S >> N) & 1 and (S >> (N + 1)) & 1: tmp -= A[m][m] coltmp[m] += A[m][m] coltmp.sort() tmp += sum(coltmp[:M-p]) ans = min(ans, tmp) print(ans)