QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#642002#7411. Bitwise Xor11d10xyWA 1ms5784kbC++141.4kb2024-10-15 08:33:072024-10-15 08:33:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-15 08:33:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5784kb
  • [2024-10-15 08:33:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64=long long;
constexpr i64 mod=998244353;
int n;i64 X,a[300010],pw[300010];
map<i64,array<vector<i64>,2>>node;
i64 solve(vector<i64>A,vector<i64>B,int h){
   if(A.empty()||B.empty())return 0;
   if(h==-1)return (pw[A.size()]-1)*(pw[B.size()]-1)%mod;
   vector<i64>a[2],b[2];
   for(int x:A)a[x>>h&1].push_back(x);
   for(int x:B)b[x>>h&1].push_back(x);
   if(X>>h&1){
      i64 x=solve(a[0],b[1],h-1),y=solve(a[1],b[0],h-1);
      return(x*pw[b[0].size()]%mod+(pw[a[0].size()]-1)*(pw[b[0].size()]-1)%mod+
             y*pw[b[1].size()]%mod+(pw[a[1].size()]-1)*(pw[b[1].size()]-1)%mod+
             x*y%mod+x*(pw[a[1].size()]-1)%mod+y*(pw[a[0].size()]-1)%mod)%mod;
   }else return(solve(a[0],b[0],h-1)+solve(a[1],b[1],h-1))%mod;
}
int main(){
   cin>>n>>X;
   for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
   pw[0]=1;for(int i=1;i<=n;i++)pw[i]=pw[i-1]*2%mod;
   if(!X){
      map<i64,int>cnt;
      for(int i=1;i<=n;i++)cnt[a[i]]++;
      i64 ans=0;
      for(auto C:cnt)(ans+=pw[C.second]-1)%=mod;
      cout<<ans;
      return 0;
   }
   int t=__lg(X);
   for(int i=1;i<=n;i++){
      node[a[i]&~((1ll<<t+1)-1)][a[i]>>t&1].push_back(a[i]&(1ll<<t)-1);
   }
   i64 ans=0;
   for(auto Sub:node){
      (ans+=solve(Sub.second[0],Sub.second[1],t-1)+pw[Sub.second[0].size()]-1+pw[Sub.second[1].size()]-1)%=mod;
   }
   cout<<ans;
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5784kb

input:

3 0
0 1 2

output:

3

result:

wrong answer 1st numbers differ - expected: '7', found: '3'