結果

問題 No.2236 Lights Out On Simple Graph
ユーザー shobonvipshobonvip
提出日時 2023-03-03 23:13:18
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 860 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 749,548 KB
最終ジャッジ日時 2023-10-18 03:31:31
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,504 KB
testcase_01 AC 42 ms
55,504 KB
testcase_02 AC 43 ms
55,504 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def popcount(n):
	c=(n&0x5555555555555555)+((n>>1)&0x5555555555555555)
	c=(c&0x3333333333333333)+((c>>2)&0x3333333333333333)
	c=(c&0x0f0f0f0f0f0f0f0f)+((c>>4)&0x0f0f0f0f0f0f0f0f)
	c=(c&0x00ff00ff00ff00ff)+((c>>8)&0x00ff00ff00ff00ff)
	c=(c&0x0000ffff0000ffff)+((c>>16)&0x0000ffff0000ffff)
	c=(c&0x00000000ffffffff)+((c>>32)&0x00000000ffffffff)
	return c


n, m = map(int,input().split())
a = [0] * m
b = [0] * m
for i in range(m):
	a[i], b[i] = map(int,input().split())
	a[i] -= 1
	b[i] -= 1

c = list(map(int,input().split()))
v = 0
for i in range(n):
	v ^= c[i] << i

r = defaultdict(lambda: 10 ** 9)
r[v] = 0

for i in range(m):
	for w, c in list(r.items()):
		x = w ^ (1 << a[i]) ^ (1 << b[i])
		if popcount(w) < popcount(x): continue
		if r[x] > c + 1:
			r[x] = c + 1

if r[0] == 10 ** 9:
	print(-1)
else:
	print(r[0])
0