結果
問題 |
No.1240 Or Sum of Xor Pair
|
ユーザー |
|
提出日時 | 2020-08-23 00:29:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,267 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 108,056 KB |
最終ジャッジ日時 | 2024-06-22 07:04:48 |
合計ジャッジ時間 | 38,115 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 1 WA * 29 |
ソースコード
import random N,X=map(int,input().split()) A=list(map(int,input().split())) def solve_square(): data_c=[[0 for j in range(512)] for i in range(512)] data_bit=[[0 for j in range(9)] for i in range(512)] cnt=[0 for i in range(512)] for i in range(N): x,y=A[i]>>9,A[i]%512 data_c[x][y]+=1 cnt[x]+=1 for j in range(9): if y>>j &1: data_bit[x][j]+=1 def all_sum(x,y): res=0 upper_const=(x^y)<<9 res+=upper_const*cnt[x]*cnt[y] for i in range(9): res+=(1<<i)*(data_bit[x][i]*(cnt[y]-data_bit[y][i])+(cnt[x]-data_bit[x][i])*data_bit[y][i]) return res def convolute(x,y): res=0 upper_const=(x^y)<<9 tmp=[0 for i in range(X%512)] for i in range(512): for j in range(512): if i^j<X%512: tmp[i^j]+=data_c[x][i]*data_c[y][j] for i in range(len(tmp)): res+=(upper_const+i)*tmp[i] return res ans=0 for i in range(512): for j in range(512): if i^j<(X>>9): ans+=all_sum(i,j) elif i^j==(X>>9): ans+=convolute(i,j) ans//=2 return ans print(solve_square())