結果
問題 | No.1900 Don't be Powers of 2 |
ユーザー | taiga0629kyopro |
提出日時 | 2022-04-09 00:22:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,603 ms / 2,000 ms |
コード長 | 2,081 bytes |
コンパイル時間 | 227 ms |
コンパイル使用メモリ | 82,208 KB |
実行使用メモリ | 326,132 KB |
最終ジャッジ日時 | 2024-05-06 10:02:41 |
合計ジャッジ時間 | 13,482 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
55,308 KB |
testcase_01 | AC | 42 ms
55,328 KB |
testcase_02 | AC | 42 ms
55,132 KB |
testcase_03 | AC | 112 ms
75,576 KB |
testcase_04 | AC | 112 ms
74,924 KB |
testcase_05 | AC | 112 ms
75,500 KB |
testcase_06 | AC | 114 ms
75,448 KB |
testcase_07 | AC | 113 ms
74,164 KB |
testcase_08 | AC | 132 ms
79,560 KB |
testcase_09 | AC | 109 ms
77,972 KB |
testcase_10 | AC | 73 ms
73,200 KB |
testcase_11 | AC | 92 ms
77,304 KB |
testcase_12 | AC | 155 ms
80,644 KB |
testcase_13 | AC | 49 ms
63,264 KB |
testcase_14 | AC | 95 ms
72,284 KB |
testcase_15 | AC | 50 ms
62,552 KB |
testcase_16 | AC | 48 ms
62,568 KB |
testcase_17 | AC | 105 ms
75,108 KB |
testcase_18 | AC | 93 ms
72,672 KB |
testcase_19 | AC | 117 ms
75,200 KB |
testcase_20 | AC | 98 ms
73,904 KB |
testcase_21 | AC | 93 ms
73,084 KB |
testcase_22 | AC | 91 ms
71,892 KB |
testcase_23 | AC | 96 ms
68,356 KB |
testcase_24 | AC | 100 ms
69,072 KB |
testcase_25 | AC | 112 ms
70,016 KB |
testcase_26 | AC | 1,540 ms
324,892 KB |
testcase_27 | AC | 285 ms
107,656 KB |
testcase_28 | AC | 166 ms
81,836 KB |
testcase_29 | AC | 162 ms
81,572 KB |
testcase_30 | AC | 95 ms
77,428 KB |
testcase_31 | AC | 42 ms
54,796 KB |
testcase_32 | AC | 41 ms
55,732 KB |
testcase_33 | AC | 1,563 ms
322,556 KB |
testcase_34 | AC | 1,591 ms
322,192 KB |
testcase_35 | AC | 1,603 ms
326,132 KB |
testcase_36 | AC | 1,297 ms
284,536 KB |
testcase_37 | AC | 173 ms
80,920 KB |
testcase_38 | AC | 343 ms
131,884 KB |
testcase_39 | AC | 187 ms
99,420 KB |
testcase_40 | AC | 167 ms
79,056 KB |
testcase_41 | AC | 210 ms
81,320 KB |
testcase_42 | AC | 41 ms
55,132 KB |
testcase_43 | AC | 41 ms
54,984 KB |
testcase_44 | AC | 41 ms
55,132 KB |
ソースコード
from collections import deque class Dinic: def __init__(self, N): self.N = N self.G = [[] for i in range(N)] def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backward = [fr, 0, forward] self.G[fr].append(forward) self.G[to].append(backward) def add_multi_edge(self, v1, v2, cap1, cap2): edge1 = [v2, cap1, None] edge1[2] = edge2 = [v1, cap2, edge1] self.G[v1].append(edge1) self.G[v2].append(edge2) def bfs(self, s, t): self.level = level = [None]*self.N deq = deque([s]) level[s] = 0 G = self.G while deq: v = deq.popleft() lv = level[v] + 1 for w, cap, _ in G[v]: if cap and level[w] is None: level[w] = lv deq.append(w) return level[t] is not None def dfs(self, v, t, f): if v == t: return f level = self.level for e in self.it[v]: w, cap, rev = e if cap and level[v] < level[w]: d = self.dfs(w, t, min(f, cap)) if d: e[1] -= d rev[1] += d return d return 0 def flow(self, s, t): flow = 0 INF = 10**9 + 7 G = self.G while self.bfs(s, t): *self.it, = map(iter, self.G) f = INF while f: f = self.dfs(s, t, INF) flow += f return flow def bc(x): res=0 for i in range(30): res+=(x>>i)&1 return res%2 n=int(input()) a=[0]+list(map(int,input().split())) ng=set() for i in range(30): ng.add(2**i) g=Dinic(n+3) for i in range(1,n+1): for j in range(i+1,n+1): if not a[i]^a[j] in ng:continue if bc(a[i])==0:g.add_edge(i,j,1) else:g.add_edge(j,i,1) for i in range(1,n+1): if bc(a[i])==0: g.add_edge(0,i,1) else: g.add_edge(i,n+1,1) ans=g.flow(0,n+1) print(n-ans)