結果
問題 | No.2236 Lights Out On Simple Graph |
ユーザー | mkawa2 |
提出日時 | 2023-03-04 11:55:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,598 ms / 4,000 ms |
コード長 | 1,323 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 283,436 KB |
最終ジャッジ日時 | 2024-09-18 01:03:09 |
合計ジャッジ時間 | 76,921 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
54,780 KB |
testcase_01 | AC | 37 ms
53,736 KB |
testcase_02 | AC | 38 ms
55,076 KB |
testcase_03 | AC | 2,598 ms
276,832 KB |
testcase_04 | AC | 1,655 ms
273,640 KB |
testcase_05 | AC | 38 ms
54,328 KB |
testcase_06 | AC | 2,263 ms
277,188 KB |
testcase_07 | AC | 2,198 ms
272,164 KB |
testcase_08 | AC | 37 ms
54,392 KB |
testcase_09 | AC | 36 ms
54,976 KB |
testcase_10 | AC | 504 ms
120,972 KB |
testcase_11 | AC | 223 ms
76,872 KB |
testcase_12 | AC | 753 ms
137,748 KB |
testcase_13 | AC | 117 ms
82,164 KB |
testcase_14 | AC | 1,551 ms
233,472 KB |
testcase_15 | AC | 102 ms
80,400 KB |
testcase_16 | AC | 144 ms
85,740 KB |
testcase_17 | AC | 274 ms
93,720 KB |
testcase_18 | AC | 62 ms
73,488 KB |
testcase_19 | AC | 233 ms
96,348 KB |
testcase_20 | AC | 1,051 ms
226,156 KB |
testcase_21 | AC | 231 ms
96,728 KB |
testcase_22 | AC | 2,563 ms
276,768 KB |
testcase_23 | AC | 2,422 ms
276,812 KB |
testcase_24 | AC | 1,568 ms
228,940 KB |
testcase_25 | AC | 409 ms
114,948 KB |
testcase_26 | AC | 2,419 ms
276,920 KB |
testcase_27 | AC | 1,081 ms
226,008 KB |
testcase_28 | AC | 1,697 ms
273,044 KB |
testcase_29 | AC | 246 ms
96,468 KB |
testcase_30 | AC | 2,419 ms
276,976 KB |
testcase_31 | AC | 2,465 ms
276,704 KB |
testcase_32 | AC | 2,538 ms
276,612 KB |
testcase_33 | AC | 2,487 ms
276,916 KB |
testcase_34 | AC | 2,446 ms
276,664 KB |
testcase_35 | AC | 2,340 ms
273,456 KB |
testcase_36 | AC | 1,975 ms
267,676 KB |
testcase_37 | AC | 2,453 ms
276,896 KB |
testcase_38 | AC | 1,760 ms
123,048 KB |
testcase_39 | AC | 1,600 ms
78,600 KB |
testcase_40 | AC | 973 ms
128,324 KB |
testcase_41 | AC | 228 ms
90,524 KB |
testcase_42 | AC | 772 ms
167,652 KB |
testcase_43 | AC | 114 ms
79,200 KB |
testcase_44 | AC | 2,045 ms
193,744 KB |
testcase_45 | AC | 2,340 ms
283,436 KB |
testcase_46 | AC | 2,190 ms
242,056 KB |
testcase_47 | AC | 2,280 ms
264,468 KB |
testcase_48 | AC | 2,263 ms
269,516 KB |
testcase_49 | AC | 2,164 ms
272,648 KB |
testcase_50 | AC | 93 ms
76,584 KB |
testcase_51 | AC | 496 ms
111,520 KB |
testcase_52 | AC | 97 ms
77,016 KB |
testcase_53 | AC | 39 ms
55,424 KB |
testcase_54 | AC | 1,454 ms
143,064 KB |
testcase_55 | AC | 1,731 ms
103,148 KB |
testcase_56 | AC | 1,687 ms
93,700 KB |
testcase_57 | AC | 1,705 ms
112,452 KB |
testcase_58 | AC | 1,673 ms
88,412 KB |
testcase_59 | AC | 1,698 ms
87,524 KB |
ソースコード
import sys # sys.setrecursionlimit(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 # inf = (1 << 31)-1 md = 10**9+7 # md = 998244353 from collections import defaultdict def popcnt(a): return bin(a).count("1") def mim(ab): res = defaultdict(lambda: inf) for s in range(1 << len(ab)): cur = 0 for i, (a, b) in enumerate(ab): if s >> i & 1: cur ^= 1 << a cur ^= 1 << b res[cur] = min(res[cur], popcnt(s)) return res n, m = LI() ab = LLI1(m) c = sum(a << i for i, a in enumerate(LI())) ll = mim(ab[:m//2]) rr = mim(ab[m//2:]) ans = inf for l in ll: r = c ^ l if r in rr: ans = min(ans, ll[l]+rr[r]) if ans == inf: ans = -1 print(ans)