結果

問題 No.2236 Lights Out On Simple Graph
ユーザー ああいいああいい
提出日時 2023-03-04 18:17:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,151 ms / 4,000 ms
コード長 805 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 169,092 KB
最終ジャッジ日時 2023-10-18 04:38:04
合計ジャッジ時間 35,642 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,448 KB
testcase_01 AC 40 ms
53,448 KB
testcase_02 AC 38 ms
53,448 KB
testcase_03 AC 1,151 ms
169,092 KB
testcase_04 AC 592 ms
136,000 KB
testcase_05 AC 38 ms
53,448 KB
testcase_06 AC 783 ms
169,092 KB
testcase_07 AC 889 ms
102,044 KB
testcase_08 AC 38 ms
53,448 KB
testcase_09 AC 39 ms
53,448 KB
testcase_10 AC 228 ms
113,528 KB
testcase_11 AC 116 ms
75,644 KB
testcase_12 AC 303 ms
113,528 KB
testcase_13 AC 70 ms
72,428 KB
testcase_14 AC 538 ms
135,996 KB
testcase_15 AC 68 ms
69,900 KB
testcase_16 AC 79 ms
74,544 KB
testcase_17 AC 149 ms
97,820 KB
testcase_18 AC 52 ms
64,388 KB
testcase_19 AC 123 ms
86,592 KB
testcase_20 AC 432 ms
135,940 KB
testcase_21 AC 121 ms
86,592 KB
testcase_22 AC 1,081 ms
169,092 KB
testcase_23 AC 1,048 ms
169,092 KB
testcase_24 AC 582 ms
135,996 KB
testcase_25 AC 174 ms
97,820 KB
testcase_26 AC 1,039 ms
169,092 KB
testcase_27 AC 448 ms
135,940 KB
testcase_28 AC 609 ms
135,996 KB
testcase_29 AC 120 ms
86,592 KB
testcase_30 AC 1,078 ms
169,092 KB
testcase_31 AC 1,073 ms
169,088 KB
testcase_32 AC 1,095 ms
169,092 KB
testcase_33 AC 1,066 ms
169,092 KB
testcase_34 AC 1,071 ms
169,092 KB
testcase_35 AC 1,024 ms
169,092 KB
testcase_36 AC 1,077 ms
169,088 KB
testcase_37 AC 1,084 ms
169,092 KB
testcase_38 AC 935 ms
113,584 KB
testcase_39 AC 816 ms
77,448 KB
testcase_40 AC 370 ms
105,636 KB
testcase_41 AC 110 ms
83,344 KB
testcase_42 AC 265 ms
93,140 KB
testcase_43 AC 76 ms
71,972 KB
testcase_44 AC 1,114 ms
122,516 KB
testcase_45 AC 1,088 ms
122,744 KB
testcase_46 AC 1,108 ms
126,696 KB
testcase_47 AC 920 ms
126,192 KB
testcase_48 AC 1,131 ms
169,092 KB
testcase_49 AC 989 ms
102,044 KB
testcase_50 AC 63 ms
66,456 KB
testcase_51 AC 193 ms
86,276 KB
testcase_52 AC 65 ms
68,644 KB
testcase_53 AC 39 ms
53,448 KB
testcase_54 AC 513 ms
113,528 KB
testcase_55 AC 947 ms
97,880 KB
testcase_56 AC 718 ms
83,304 KB
testcase_57 AC 782 ms
90,564 KB
testcase_58 AC 858 ms
86,332 KB
testcase_59 AC 839 ms
83,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
edge = []
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edge.append((1 << a) | (1 << b))
c = list(map(int,input().split()))
C = 0
for i in range(N):
    if c[i] == 1:
        C |= 1 << i
import sys
D = M // 2
E = M - D
d = dict()
for bit in range(1 << D):
    count = 0
    tmp = 0
    for i in range(D):
        if bit >> i & 1:
            count += 1
            tmp ^= edge[i]
    if tmp in d:
        d[tmp] = min(d[tmp],count)
    else:
        d[tmp] = count
ans = 50
for bit in range(1 << E):
    count = 0
    tmp = 0
    for i in range(E):
        if bit >> i & 1:
            count += 1
            tmp ^= edge[D + i]
    if tmp ^ C in d:
        ans = min(ans,count + d[tmp ^ C])
if ans == 50:
    print(-1)
else:
    print(ans)
0