結果
問題 | No.943 取り調べ |
ユーザー | mkawa2 |
提出日時 | 2021-04-07 16:23:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,265 bytes |
コンパイル時間 | 1,961 ms |
コンパイル使用メモリ | 86,824 KB |
実行使用メモリ | 79,580 KB |
最終ジャッジ日時 | 2023-09-04 19:14:05 |
合計ジャッジ時間 | 7,143 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
71,248 KB |
testcase_01 | AC | 71 ms
71,444 KB |
testcase_02 | AC | 72 ms
71,068 KB |
testcase_03 | AC | 76 ms
71,548 KB |
testcase_04 | AC | 737 ms
78,976 KB |
testcase_05 | AC | 258 ms
77,744 KB |
testcase_06 | AC | 281 ms
77,304 KB |
testcase_07 | AC | 73 ms
71,236 KB |
testcase_08 | AC | 1,056 ms
79,204 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 74 ms
71,168 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 79 ms
76,244 KB |
testcase_16 | AC | 73 ms
71,164 KB |
testcase_17 | AC | 299 ms
78,580 KB |
testcase_18 | AC | 73 ms
71,372 KB |
testcase_19 | AC | 96 ms
76,448 KB |
testcase_20 | AC | 81 ms
75,568 KB |
testcase_21 | WA | - |
testcase_22 | AC | 410 ms
79,040 KB |
testcase_23 | WA | - |
ソースコード
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # 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)] dij = [(0, 1), (1, 0), (1, 1), (1, -1)] inf = 10**19 # md = 998244353 md = 10**9+7 n = II() ss = [] for u in range(n): s = SI() s = s.replace(" ", "") ss.append(int(s[::-1], 2)) aa = LI() def ok(bit, ss): for _ in range(n): nss = [] for u, s in enumerate(ss): if bit & s == s: bit |= 1 << u else: nss.append(s) if not nss: return True ss = nss return False ans = inf for bit in range(1 << n): cost = sum(aa[u] for u in range(n) if bit >> u & 1) if cost >= ans: continue if ok(bit, ss[:]): ans = cost print(ans)