QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642001#7411. Bitwise Xor11d10xyWA 0ms3612kbC++141.4kb2024-10-15 08:31:532024-10-15 08:31:54

Judging History

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

  • [2024-10-15 08:31:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-10-15 08:31:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64=long long;
using u32=unsigned;
constexpr i64 mod=998244353;
int n;u32 X,a[200010];i64 pw[200010];
map<u32,array<vector<u32>,2>>node;
i64 solve(vector<u32>A,vector<u32>B,int h){
   if(A.empty()||B.empty())return 0;
   if(h==-1)return (pw[A.size()]-1)*(pw[B.size()]-1)%mod;
   vector<u32>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("%u",&a[i]);
   pw[0]=1;for(int i=1;i<=n;i++)pw[i]=pw[i-1]*2%mod;
   if(!X){
      map<u32,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]&~((1u<<t+1)-1)][a[i]>>t&1].push_back(a[i]&(1u<<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;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3612kb

input:

3 0
0 1 2

output:

3

result:

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