結果
問題 |
No.1240 Or Sum of Xor Pair
|
ユーザー |
|
提出日時 | 2020-08-23 00:21:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,251 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 108,288 KB |
最終ジャッジ日時 | 2024-06-22 06:59:16 |
合計ジャッジ時間 | 9,477 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 1 WA * 2 RE * 27 |
ソースコード
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<<j)*(data_bit[x][j]*(cnt[y]-data_bit[y][j])+(cnt[x]-data_bit[x][j])*data_bit[y][j]) 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())