結果
問題 | No.1900 Don't be Powers of 2 |
ユーザー | googol_S0 |
提出日時 | 2022-04-08 21:37:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,092 ms / 2,000 ms |
コード長 | 1,340 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 86,944 KB |
実行使用メモリ | 321,656 KB |
最終ジャッジ日時 | 2023-08-19 00:17:00 |
合計ジャッジ時間 | 13,864 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 95 ms
71,012 KB |
testcase_01 | AC | 97 ms
71,196 KB |
testcase_02 | AC | 101 ms
70,856 KB |
testcase_03 | AC | 170 ms
78,056 KB |
testcase_04 | AC | 166 ms
77,876 KB |
testcase_05 | AC | 174 ms
78,136 KB |
testcase_06 | AC | 166 ms
77,876 KB |
testcase_07 | AC | 170 ms
78,200 KB |
testcase_08 | AC | 218 ms
80,676 KB |
testcase_09 | AC | 218 ms
79,228 KB |
testcase_10 | AC | 170 ms
77,788 KB |
testcase_11 | AC | 175 ms
78,200 KB |
testcase_12 | AC | 246 ms
82,296 KB |
testcase_13 | AC | 112 ms
76,312 KB |
testcase_14 | AC | 174 ms
78,160 KB |
testcase_15 | AC | 119 ms
76,412 KB |
testcase_16 | AC | 129 ms
76,972 KB |
testcase_17 | AC | 176 ms
78,212 KB |
testcase_18 | AC | 158 ms
78,076 KB |
testcase_19 | AC | 167 ms
78,128 KB |
testcase_20 | AC | 159 ms
77,800 KB |
testcase_21 | AC | 152 ms
77,600 KB |
testcase_22 | AC | 151 ms
77,856 KB |
testcase_23 | AC | 151 ms
77,648 KB |
testcase_24 | AC | 139 ms
77,452 KB |
testcase_25 | AC | 149 ms
77,252 KB |
testcase_26 | AC | 898 ms
320,120 KB |
testcase_27 | AC | 309 ms
106,392 KB |
testcase_28 | AC | 221 ms
83,388 KB |
testcase_29 | AC | 237 ms
82,900 KB |
testcase_30 | AC | 179 ms
78,204 KB |
testcase_31 | AC | 112 ms
71,204 KB |
testcase_32 | AC | 108 ms
71,068 KB |
testcase_33 | AC | 1,009 ms
321,656 KB |
testcase_34 | AC | 965 ms
319,848 KB |
testcase_35 | AC | 1,092 ms
320,652 KB |
testcase_36 | AC | 687 ms
255,048 KB |
testcase_37 | AC | 205 ms
81,976 KB |
testcase_38 | AC | 287 ms
129,020 KB |
testcase_39 | AC | 197 ms
89,064 KB |
testcase_40 | AC | 243 ms
80,652 KB |
testcase_41 | AC | 271 ms
82,896 KB |
testcase_42 | AC | 103 ms
70,724 KB |
testcase_43 | AC | 103 ms
71,032 KB |
testcase_44 | AC | 98 ms
71,124 KB |
ソースコード
from collections import deque N=int(input()) A=sorted(map(int,input().split())) N=len(A) V=N+2 G=[[] for i in range(V)] L=[0]*V I=[0]*V INF=10**15 def ae(fr,to,ca): global G G[fr].append([to,ca,len(G[to]),0]) G[to].append([fr,0,len(G[fr])-1,0]) def bfs(s): global INF,L,V,G L=[-1]*V Q=deque() L[s]=0 Q.append(s) while(len(Q)): x=Q.popleft() for i in range(len(G[x])): if G[x][i][1]>0 and L[G[x][i][0]]<0: L[G[x][i][0]]=L[x]+1 Q.append(G[x][i][0]) def dfs(v,t,f): global I,G,V if v==t: return f for i in range(I[v],len(G[v])): if G[v][i][1]>0 and L[v]<L[G[v][i][0]]: d=dfs(G[v][i][0],t,min(f,G[v][i][1])) if d>0: G[v][i][1]-=d G[v][i][3]+=d G[G[v][i][0]][G[v][i][2]][1]+=d G[G[v][i][0]][G[v][i][2]][3]-=d return d I[v]+=1 return 0 def mf(s,t): global L,I,INF,V fl=0 while(True): bfs(s) if L[t]<0: break I=[0]*V f=0 while(True): f=dfs(s,t,INF) if f<=0: break fl+=f return fl D=dict() BB=set([1<<i for i in range(31)]) for i in range(N): f=0 if bin(A[i]).count('1')&1: ae(i,V-1,1) f=1 else: ae(V-2,i,1) D[A[i]]=i for j in range(i): if A[i]^A[j] in BB: if f: ae(j,i,1) else: ae(i,j,1) print(N-mf(V-2,V-1))