結果
問題 | No.2236 Lights Out On Simple Graph |
ユーザー | 👑 seekworser |
提出日時 | 2023-03-01 05:04:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,231 bytes |
コンパイル時間 | 2,282 ms |
コンパイル使用メモリ | 86,744 KB |
実行使用メモリ | 261,012 KB |
最終ジャッジ日時 | 2023-10-15 02:41:16 |
合計ジャッジ時間 | 47,413 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
71,480 KB |
testcase_01 | AC | 69 ms
71,448 KB |
testcase_02 | AC | 70 ms
71,372 KB |
testcase_03 | AC | 1,484 ms
260,352 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 1,030 ms
123,348 KB |
testcase_08 | AC | 66 ms
71,396 KB |
testcase_09 | AC | 69 ms
71,396 KB |
testcase_10 | WA | - |
testcase_11 | AC | 160 ms
77,424 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 | 1,289 ms
260,096 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 898 ms
80,648 KB |
testcase_40 | AC | 494 ms
145,132 KB |
testcase_41 | AC | 159 ms
98,220 KB |
testcase_42 | WA | - |
testcase_43 | AC | 114 ms
80,776 KB |
testcase_44 | AC | 1,311 ms
189,904 KB |
testcase_45 | AC | 1,287 ms
190,460 KB |
testcase_46 | AC | 1,352 ms
169,732 KB |
testcase_47 | WA | - |
testcase_48 | AC | 1,505 ms
260,468 KB |
testcase_49 | AC | 1,187 ms
123,360 KB |
testcase_50 | AC | 102 ms
76,720 KB |
testcase_51 | AC | 273 ms
95,868 KB |
testcase_52 | AC | 101 ms
76,720 KB |
testcase_53 | AC | 72 ms
71,136 KB |
testcase_54 | WA | - |
testcase_55 | AC | 1,120 ms
120,312 KB |
testcase_56 | WA | - |
testcase_57 | AC | 958 ms
104,860 KB |
testcase_58 | AC | 992 ms
92,156 KB |
testcase_59 | WA | - |
ソースコード
MSK1 = 0x5555555555555555 MSK2 = 0x3333333333333333 MSK3 = 0x0f0f0f0f0f0f0f0f MSK4 = 0x00ff00ff00ff00ff MSK5 = 0x0000ffff0000ffff MSK6 = 0x00000000ffffffff 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) 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)