結果

問題 No.1900 Don't be Powers of 2
ユーザー googol_S0googol_S0
提出日時 2022-04-08 21:34:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,329 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 82,748 KB
最終ジャッジ日時 2023-08-19 00:14:32
合計ジャッジ時間 7,412 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,492 KB
testcase_01 AC 90 ms
71,572 KB
testcase_02 AC 91 ms
71,684 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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 AC 88 ms
71,828 KB
testcase_32 AC 87 ms
71,576 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 167 ms
82,748 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 88 ms
71,860 KB
testcase_43 AC 90 ms
71,604 KB
testcase_44 AC 87 ms
71,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N=int(input())
A=sorted(set(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()
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(30):
    v=D.get(A[i]^(1<<j),-1)
    if v>=0:
      if f:
        ae(v,i,1)
      else:
        ae(i,v,1)
print(N-mf(V-2,V-1))
0