結果
問題 | No.1345 Beautiful BINGO |
ユーザー | mkawa2 |
提出日時 | 2023-05-10 15:08:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,262 ms / 2,000 ms |
コード長 | 2,019 bytes |
コンパイル時間 | 249 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 77,568 KB |
最終ジャッジ日時 | 2024-05-05 03:17:25 |
合計ジャッジ時間 | 20,187 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,608 KB |
testcase_01 | AC | 38 ms
52,608 KB |
testcase_02 | AC | 39 ms
52,864 KB |
testcase_03 | AC | 38 ms
52,992 KB |
testcase_04 | AC | 37 ms
52,864 KB |
testcase_05 | AC | 55 ms
64,512 KB |
testcase_06 | AC | 37 ms
52,736 KB |
testcase_07 | AC | 96 ms
76,672 KB |
testcase_08 | AC | 41 ms
52,608 KB |
testcase_09 | AC | 38 ms
52,608 KB |
testcase_10 | AC | 46 ms
60,160 KB |
testcase_11 | AC | 51 ms
63,104 KB |
testcase_12 | AC | 37 ms
52,608 KB |
testcase_13 | AC | 97 ms
76,544 KB |
testcase_14 | AC | 43 ms
58,496 KB |
testcase_15 | AC | 38 ms
52,352 KB |
testcase_16 | AC | 47 ms
61,056 KB |
testcase_17 | AC | 40 ms
52,864 KB |
testcase_18 | AC | 38 ms
52,224 KB |
testcase_19 | AC | 40 ms
52,736 KB |
testcase_20 | AC | 39 ms
52,480 KB |
testcase_21 | AC | 38 ms
52,736 KB |
testcase_22 | AC | 112 ms
76,544 KB |
testcase_23 | AC | 416 ms
76,544 KB |
testcase_24 | AC | 266 ms
76,800 KB |
testcase_25 | AC | 137 ms
77,056 KB |
testcase_26 | AC | 337 ms
76,928 KB |
testcase_27 | AC | 1,200 ms
77,440 KB |
testcase_28 | AC | 127 ms
77,056 KB |
testcase_29 | AC | 344 ms
76,928 KB |
testcase_30 | AC | 123 ms
76,544 KB |
testcase_31 | AC | 136 ms
76,544 KB |
testcase_32 | AC | 107 ms
77,312 KB |
testcase_33 | AC | 1,227 ms
77,568 KB |
testcase_34 | AC | 98 ms
76,416 KB |
testcase_35 | AC | 110 ms
76,804 KB |
testcase_36 | AC | 563 ms
77,056 KB |
testcase_37 | AC | 93 ms
76,416 KB |
testcase_38 | AC | 332 ms
77,184 KB |
testcase_39 | AC | 1,242 ms
77,568 KB |
testcase_40 | AC | 595 ms
76,928 KB |
testcase_41 | AC | 377 ms
77,056 KB |
testcase_42 | AC | 37 ms
52,480 KB |
testcase_43 | AC | 36 ms
52,608 KB |
testcase_44 | AC | 36 ms
52,864 KB |
testcase_45 | AC | 36 ms
52,864 KB |
testcase_46 | AC | 36 ms
52,736 KB |
testcase_47 | AC | 35 ms
52,480 KB |
testcase_48 | AC | 35 ms
52,480 KB |
testcase_49 | AC | 35 ms
52,480 KB |
testcase_50 | AC | 35 ms
52,480 KB |
testcase_51 | AC | 35 ms
52,352 KB |
testcase_52 | AC | 417 ms
76,928 KB |
testcase_53 | AC | 1,262 ms
77,184 KB |
testcase_54 | AC | 550 ms
77,184 KB |
testcase_55 | AC | 743 ms
77,184 KB |
testcase_56 | AC | 432 ms
76,544 KB |
testcase_57 | AC | 1,147 ms
77,056 KB |
testcase_58 | AC | 1,125 ms
76,928 KB |
testcase_59 | AC | 1,228 ms
77,440 KB |
testcase_60 | AC | 699 ms
76,800 KB |
testcase_61 | AC | 919 ms
77,184 KB |
testcase_62 | AC | 418 ms
76,672 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # md = 10**9+7 md = 998244353 def popcnt(a): return bin(a).count("1") def f(s, m): if m == 0: return 0 if m < 0 or m > n: return inf cc = [] for j in range(n): cur = 0 for i in range(n): if s >> i & 1: continue cur += a[i][j] cc.append(cur) cc.sort() return sum(cc[:m]) n, m = LI() ori = LLI(n) ans = inf a = [r[:] for r in ori] pre = 0 for s in range(1 << n): row = 0 for i in range(n): if s >> i & 1: row += sum(a[i]) ans=min(ans,f(s,m-popcnt(s))+pre+row) a = [r[:] for r in ori] pre = 0 for i in range(n): pre += a[i][i] a[i][i] = 0 for s in range(1 << n): row = 0 for i in range(n): if s >> i & 1: row += sum(a[i]) ans=min(ans,f(s,m-popcnt(s)-1)+pre+row) a = [r[:] for r in ori] pre = 0 for i in range(n): pre += a[i][n-1-i] a[i][n-1-i] = 0 for s in range(1 << n): row = 0 for i in range(n): if s >> i & 1: row += sum(a[i]) ans=min(ans,f(s,m-popcnt(s)-1)+pre+row) a = [r[:] for r in ori] pre = 0 for i in range(n): pre += a[i][i] a[i][i] = 0 pre += a[i][n-1-i] a[i][n-1-i] = 0 for s in range(1 << n): row = 0 for i in range(n): if s >> i & 1: row += sum(a[i]) ans=min(ans,f(s,m-popcnt(s)-2)+pre+row) print(ans)