結果
問題 | No.2236 Lights Out On Simple Graph |
ユーザー | 👑 seekworser |
提出日時 | 2023-03-01 05:11:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,389 bytes |
コンパイル時間 | 1,562 ms |
コンパイル使用メモリ | 87,076 KB |
実行使用メモリ | 286,308 KB |
最終ジャッジ日時 | 2023-10-15 02:42:41 |
合計ジャッジ時間 | 84,227 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
71,304 KB |
testcase_01 | AC | 77 ms
71,560 KB |
testcase_02 | AC | 76 ms
71,168 KB |
testcase_03 | AC | 2,621 ms
286,308 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 2,069 ms
179,692 KB |
testcase_08 | AC | 76 ms
71,348 KB |
testcase_09 | AC | 76 ms
71,276 KB |
testcase_10 | WA | - |
testcase_11 | AC | 331 ms
77,876 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,451 ms
276,096 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 2,539 ms
81,816 KB |
testcase_40 | AC | 1,058 ms
177,164 KB |
testcase_41 | AC | 231 ms
93,112 KB |
testcase_42 | WA | - |
testcase_43 | AC | 154 ms
81,548 KB |
testcase_44 | AC | 2,442 ms
278,396 KB |
testcase_45 | AC | 2,352 ms
273,516 KB |
testcase_46 | AC | 2,435 ms
272,420 KB |
testcase_47 | WA | - |
testcase_48 | AC | 2,698 ms
285,664 KB |
testcase_49 | AC | 2,150 ms
179,796 KB |
testcase_50 | AC | 138 ms
77,520 KB |
testcase_51 | AC | 514 ms
99,564 KB |
testcase_52 | AC | 127 ms
78,932 KB |
testcase_53 | AC | 76 ms
71,480 KB |
testcase_54 | WA | - |
testcase_55 | AC | 2,229 ms
124,176 KB |
testcase_56 | WA | - |
testcase_57 | AC | 1,922 ms
126,532 KB |
testcase_58 | AC | 1,946 ms
102,232 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)