結果
問題 | No.1240 Or Sum of Xor Pair |
ユーザー |
|
提出日時 | 2020-08-23 12:00:52 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,259 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 107,332 KB |
最終ジャッジ日時 | 2024-06-22 07:01:17 |
合計ジャッジ時間 | 5,154 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 1 WA * 15 TLE * 14 |
ソースコード
import random N,X=map(int,input().split()) A=list(map(int,input().split())) def solve_tri(): data_c=[[0 for j in range(64)] for i in range(4096)] data_bit=[[0 for j in range(6)] for i in range(4096)] cnt=[0 for i in range(4096)] for i in range(N): x,y=A[i]>>6,A[i]%64 data_c[x][y]+=1 cnt[x]+=1 for j in range(6): if y>>j &1: data_bit[x][j]+=1 def all_sum(x,y): res=0 upper_const=(x^y)<<6 res+=upper_const*cnt[x]*cnt[y] for i in range(6): 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)<<6 tmp=[0 for i in range(X%64)] for i in range(64): for j in range(64): if i^j<X%64: 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(4096): for j in range(4096): if i^j<(X>>6): ans+=all_sum(i,j) elif i^j==(X>>6): ans+=convolute(i,j) ans//=2 return ans print(solve_tri())