結果

問題 No.2236 Lights Out On Simple Graph
ユーザー mkawa2mkawa2
提出日時 2023-03-04 12:03:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,364 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 81,608 KB
実行使用メモリ 270,028 KB
最終ジャッジ日時 2023-10-18 04:18:31
合計ジャッジ時間 28,439 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,428 KB
testcase_01 AC 43 ms
55,428 KB
testcase_02 AC 43 ms
55,428 KB
testcase_03 AC 929 ms
262,928 KB
testcase_04 AC 663 ms
261,216 KB
testcase_05 AC 43 ms
55,436 KB
testcase_06 AC 756 ms
262,940 KB
testcase_07 AC 693 ms
267,624 KB
testcase_08 AC 43 ms
55,436 KB
testcase_09 WA -
testcase_10 AC 212 ms
141,208 KB
testcase_11 AC 89 ms
74,708 KB
testcase_12 AC 297 ms
153,744 KB
testcase_13 AC 75 ms
77,348 KB
testcase_14 AC 535 ms
194,804 KB
testcase_15 AC 70 ms
74,292 KB
testcase_16 AC 87 ms
86,104 KB
testcase_17 AC 134 ms
108,524 KB
testcase_18 WA -
testcase_19 AC 119 ms
104,272 KB
testcase_20 AC 423 ms
186,432 KB
testcase_21 AC 117 ms
104,288 KB
testcase_22 AC 888 ms
262,932 KB
testcase_23 AC 894 ms
262,936 KB
testcase_24 AC 576 ms
194,800 KB
testcase_25 AC 182 ms
139,136 KB
testcase_26 AC 883 ms
262,940 KB
testcase_27 AC 444 ms
186,308 KB
testcase_28 AC 640 ms
261,220 KB
testcase_29 AC 116 ms
104,288 KB
testcase_30 AC 856 ms
262,936 KB
testcase_31 AC 869 ms
262,940 KB
testcase_32 AC 907 ms
262,940 KB
testcase_33 AC 872 ms
262,936 KB
testcase_34 AC 904 ms
262,940 KB
testcase_35 AC 756 ms
263,208 KB
testcase_36 AC 509 ms
224,868 KB
testcase_37 AC 887 ms
262,948 KB
testcase_38 AC 306 ms
151,768 KB
testcase_39 WA -
testcase_40 AC 307 ms
139,888 KB
testcase_41 AC 107 ms
95,908 KB
testcase_42 AC 296 ms
149,060 KB
testcase_43 AC 84 ms
77,808 KB
testcase_44 AC 554 ms
175,248 KB
testcase_45 AC 853 ms
263,756 KB
testcase_46 AC 680 ms
217,628 KB
testcase_47 AC 777 ms
270,028 KB
testcase_48 AC 755 ms
225,308 KB
testcase_49 AC 715 ms
267,624 KB
testcase_50 WA -
testcase_51 AC 204 ms
138,372 KB
testcase_52 AC 77 ms
73,296 KB
testcase_53 AC 43 ms
55,436 KB
testcase_54 AC 444 ms
145,424 KB
testcase_55 AC 328 ms
131,116 KB
testcase_56 AC 276 ms
130,656 KB
testcase_57 AC 322 ms
131,380 KB
testcase_58 WA -
testcase_59 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 mim(ab):
    res = defaultdict(lambda: inf)
    n = len(ab)
    pc = [0]*(1 << n)
    dp = [0]*(1 << n)
    for s in range(1, 1 << len(ab)):
        i = s.bit_length()-1
        pc[s] = pc[s ^ 1 << i]+1
        dp[s] = dp[s ^ 1 << i]
        a, b = ab[i]
        dp[s] ^= 1 << a
        dp[s] ^= 1 << b
        res[dp[s]] = min(res[dp[s]], pc[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)
0