結果
問題 | No.2236 Lights Out On Simple Graph |
ユーザー | 👑 seekworser |
提出日時 | 2023-03-01 05:06:51 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 878 bytes |
コンパイル時間 | 940 ms |
コンパイル使用メモリ | 86,724 KB |
実行使用メモリ | 264,628 KB |
最終ジャッジ日時 | 2023-10-15 02:44:32 |
合計ジャッジ時間 | 66,833 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
70,860 KB |
testcase_01 | AC | 69 ms
70,856 KB |
testcase_02 | AC | 66 ms
71,184 KB |
testcase_03 | AC | 2,207 ms
259,696 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 1,594 ms
143,596 KB |
testcase_08 | AC | 70 ms
71,308 KB |
testcase_09 | AC | 70 ms
71,248 KB |
testcase_10 | WA | - |
testcase_11 | AC | 261 ms
77,376 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,936 ms
262,552 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 1,798 ms
79,608 KB |
testcase_40 | AC | 779 ms
142,704 KB |
testcase_41 | AC | 203 ms
90,288 KB |
testcase_42 | WA | - |
testcase_43 | AC | 128 ms
80,364 KB |
testcase_44 | AC | 1,818 ms
205,432 KB |
testcase_45 | AC | 1,897 ms
214,760 KB |
testcase_46 | AC | 1,860 ms
230,952 KB |
testcase_47 | WA | - |
testcase_48 | AC | 2,275 ms
259,888 KB |
testcase_49 | AC | 1,695 ms
143,560 KB |
testcase_50 | AC | 122 ms
77,112 KB |
testcase_51 | AC | 384 ms
88,076 KB |
testcase_52 | AC | 111 ms
77,592 KB |
testcase_53 | AC | 70 ms
70,864 KB |
testcase_54 | WA | - |
testcase_55 | AC | 1,668 ms
98,704 KB |
testcase_56 | WA | - |
testcase_57 | AC | 1,423 ms
103,504 KB |
testcase_58 | AC | 1,459 ms
90,900 KB |
testcase_59 | WA | - |
ソースコード
def popcnt(n): return bin(n).count("1") 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)