結果
問題 | No.1900 Don't be Powers of 2 |
ユーザー | taiga0629kyopro |
提出日時 | 2022-04-08 23:41:44 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 3,783 bytes |
コンパイル時間 | 334 ms |
コンパイル使用メモリ | 81,968 KB |
実行使用メモリ | 905,688 KB |
最終ジャッジ日時 | 2024-11-28 14:56:50 |
合計ジャッジ時間 | 24,287 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | MLE | - |
testcase_01 | AC | 42 ms
63,188 KB |
testcase_02 | MLE | - |
testcase_03 | AC | 142 ms
85,892 KB |
testcase_04 | AC | 140 ms
78,804 KB |
testcase_05 | AC | 138 ms
78,928 KB |
testcase_06 | AC | 139 ms
78,936 KB |
testcase_07 | AC | 144 ms
78,992 KB |
testcase_08 | AC | 165 ms
83,860 KB |
testcase_09 | AC | 130 ms
80,680 KB |
testcase_10 | AC | 95 ms
77,692 KB |
testcase_11 | AC | 109 ms
78,820 KB |
testcase_12 | AC | 189 ms
86,512 KB |
testcase_13 | AC | 50 ms
64,444 KB |
testcase_14 | AC | 116 ms
78,832 KB |
testcase_15 | AC | 53 ms
63,516 KB |
testcase_16 | AC | 49 ms
63,976 KB |
testcase_17 | AC | 134 ms
78,900 KB |
testcase_18 | AC | 120 ms
78,880 KB |
testcase_19 | AC | 140 ms
78,808 KB |
testcase_20 | AC | 122 ms
79,000 KB |
testcase_21 | AC | 116 ms
78,912 KB |
testcase_22 | AC | 113 ms
78,612 KB |
testcase_23 | AC | 105 ms
72,196 KB |
testcase_24 | AC | 110 ms
72,108 KB |
testcase_25 | AC | 120 ms
74,608 KB |
testcase_26 | TLE | - |
testcase_27 | AC | 480 ms
180,040 KB |
testcase_28 | AC | 210 ms
91,124 KB |
testcase_29 | AC | 208 ms
90,372 KB |
testcase_30 | AC | 93 ms
78,216 KB |
testcase_31 | AC | 43 ms
55,752 KB |
testcase_32 | AC | 44 ms
54,512 KB |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | TLE | - |
testcase_36 | TLE | - |
testcase_37 | AC | 229 ms
88,072 KB |
testcase_38 | AC | 603 ms
268,768 KB |
testcase_39 | AC | 314 ms
152,836 KB |
testcase_40 | AC | 186 ms
81,824 KB |
testcase_41 | AC | 252 ms
90,508 KB |
testcase_42 | AC | 43 ms
55,368 KB |
testcase_43 | AC | 42 ms
55,244 KB |
testcase_44 | MLE | - |
ソースコード
from collections import deque class mf_graph: n=1 g=[[] for i in range(1)] pos=[] def __init__(self,N): self.n=N self.g=[[] for i in range(N)] self.pos=[] def add_edge(self,From,To,cap): assert 0<=From and From<self.n assert 0<=To and To<self.n assert 0<=cap m=len(self.pos) self.pos.append((From,len(self.g[From]))) self.g[From].append({"to":To,"rev":len(self.g[To]),"cap":cap}) self.g[To].append({"to":From,"rev":len(self.g[From])-1,"cap":0}) return m def get_edge(self,i): m=len(self.pos) assert 0<=i and i<m _e=self.g[self.pos[i][0]][self.pos[i][1]] _re=self.g[_e["to"]][_e["rev"]] return {"from":self.pos[i][0], "to":_e["to"], "cap":_e["cap"]+_re["cap"], "flow":_re["cap"]} def edges(self): m=len(self.pos) result=[] for i in range(m): result.append(self.get_edge(i)) return result def change_edge(self,i,new_cap,new_flow): m=len(self.pos) assert 0<=i and i<m assert 0<=new_flow and new_flow<=new_cap _e=self.g[self.pos[i][0]][self.pos[i][1]] _re=self.g[_e["to"]][_e["rev"]] _e["cap"]=new_cap-new_flow _re["cap"]=new_flow def flow(self,s,t,flow_limit=(1<<63)-1): assert 0<=s and s<self.n assert 0<=t and t<self.n level=[0 for i in range(self.n)] Iter=[0 for i in range(self.n)] que=deque([]) def bfs(): for i in range(self.n):level[i]=-1 level[s]=0 que=deque([]) que.append(s) while(len(que)>0): v=que.popleft() for e in self.g[v]: if e["cap"]==0 or level[e["to"]]>=0:continue level[e["to"]]=level[v]+1 if e["to"]==t:return que.append(e["to"]) def dfs(func,v,up): if (v==s):return up res=0 level_v=level[v] for i in range(Iter[v],len(self.g[v])): e=self.g[v][i] if (level_v<=level[e["to"]] or self.g[e["to"]][e["rev"]]["cap"]==0):continue d=func(func,e["to"],min(up-res,self.g[e["to"]][e["rev"]]["cap"])) if d<=0:continue self.g[v][i]["cap"]+=d self.g[e["to"]][e["rev"]]["cap"]-=d res+=d if res==up:return res level[v]=self.n return res flow=0 while(flow<flow_limit): bfs() if level[t]==-1:break for i in range(self.n):Iter[i]=0 while(flow<flow_limit): f=dfs(dfs,t,flow_limit-flow) if not(f):break flow+=f return flow def min_cut(self,s): visited=[False for i in range(self.n)] que=deque([]) que.append(s) while(len(que)>0): p=que.popleft() visited[p]=True for e in self.g[p]: if e["cap"] and not(visited[e["to"]]): visited[e["to"]]=True que.append(e["to"]) return visited 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=mf_graph(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)