結果
問題 | No.2236 Lights Out On Simple Graph |
ユーザー | 👑 seekworser |
提出日時 | 2023-03-01 05:11:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,389 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 298,988 KB |
最終ジャッジ日時 | 2024-09-16 20:14:40 |
合計ジャッジ時間 | 78,730 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,224 KB |
testcase_01 | AC | 39 ms
52,352 KB |
testcase_02 | AC | 38 ms
52,096 KB |
testcase_03 | AC | 2,599 ms
298,628 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 1,951 ms
173,920 KB |
testcase_08 | AC | 38 ms
52,736 KB |
testcase_09 | AC | 38 ms
52,224 KB |
testcase_10 | WA | - |
testcase_11 | AC | 289 ms
76,800 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 2,422 ms
298,348 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 2,267 ms
80,640 KB |
testcase_40 | AC | 961 ms
171,776 KB |
testcase_41 | AC | 190 ms
89,856 KB |
testcase_42 | WA | - |
testcase_43 | AC | 116 ms
79,440 KB |
testcase_44 | AC | 2,330 ms
271,664 KB |
testcase_45 | AC | 2,261 ms
266,480 KB |
testcase_46 | AC | 2,354 ms
281,412 KB |
testcase_47 | WA | - |
testcase_48 | AC | 2,637 ms
298,248 KB |
testcase_49 | AC | 2,061 ms
174,048 KB |
testcase_50 | AC | 105 ms
76,144 KB |
testcase_51 | AC | 436 ms
94,188 KB |
testcase_52 | AC | 92 ms
76,928 KB |
testcase_53 | AC | 39 ms
52,608 KB |
testcase_54 | WA | - |
testcase_55 | AC | 2,073 ms
114,244 KB |
testcase_56 | WA | - |
testcase_57 | AC | 1,802 ms
122,268 KB |
testcase_58 | AC | 1,781 ms
97,728 KB |
testcase_59 | WA | - |
ソースコード
MSK1 = 0x55555555555555555555555555555555 MSK2 = 0x33333333333333333333333333333333 MSK3 = 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f MSK4 = 0x00ff00ff00ff00ff00ff00ff00ff00ff MSK5 = 0x0000ffff0000ffff0000ffff0000ffff MSK6 = 0x00000000ffffffff00000000ffffffff MSK7 = 0x0000000000000000ffffffffffffffff def popcnt(x): x=(x & MSK1) + ((x>>1) & MSK1) x=(x & MSK2) + ((x>>2) & MSK2) x=(x & MSK3) + ((x>>4) & MSK3) x=(x & MSK4) + ((x>>8) & MSK4) x=(x & MSK5) + ((x>>16) & MSK5) x=(x & MSK6) + ((x>>32) & MSK6) x=(x & MSK7) + ((x>>64) & MSK7) return x n,m = map(int,input().split()) a = [] b = [] for _ in range(m): ai, bi = map(int,input().split()) a.append(ai-1) b.append(bi-1) cv = list(map(int,input().split())) c = 0 for i in range(n): if cv[i]: c += (1 << i) seen = set() val = dict() m1 = m // 2 m2 = m - m1 for bt in range((1 << m1)): l = 0 for i in range(m1): if (bt >> i) & 1: l ^= (1 << a[i]) l ^= (1 << b[i]) if l in seen: val[l] = min(val[l], popcnt(bt)) else: val[l] = popcnt(l) seen.add(l) ans = 100000000 for bt in range(1 << m2): l = c for i in range(m2): if (bt >> i) & 1: l ^= (1 << a[m1+i]) l ^= (1 << b[m1+i]) if l in seen: ans = min(ans, val[l] + popcnt(bt)) if ans == 100000000: print(-1) else: print(ans)