QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372048 | #3013. XOR Sequences | InfinityNS# | WA | 1ms | 3904kb | C++14 | 1.1kb | 2024-03-30 20:09:24 | 2024-03-30 20:09:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int add(int x,int y){x+=y;return x>=mod?x-mod:x;}
int mul(int x,int y){return (ll)x*y%mod;}
const int N=(1<<17)+50;
int p[N],L[N],R[N],cnt[N],po[N];
bool was[N];
int ans=1;
void Solve(int l,int r,int lvl){
if(p[l]==p[r]){
if(was[p[l]])ans=0;
was[p[l]]=true;
ans=mul(ans,po[lvl]);
}else{
int mid=l+r>>1;
Solve(l,mid,lvl-1);
Solve(mid+1,r,lvl-1);
}
}
int main(){
int m,n;
scanf("%i %i",&m,&n);
for(int i=1;i<=n;i++)L[i]=(1<<m)+1,R[i]=-1;
for(int i=0;i<(1<<m);i++){
scanf("%i",&p[i]);
}
for(int j=m-1;j>=0;j--){
bool ok=true;
for(int i=0;i<(1<<m);i++){
if(p[i]!=p[i^(1<<j)])ok=false;
}
if(ok){
ans=mul(ans,2);
int ptr=0;
for(int i=0;i<(1<<m);i++){
if(i>>j&1){
p[ptr++]=p[i];
}
}
m--;
}
}
for(int i=0;i<(1<<m);i++){
L[p[i]]=min(L[p[i]],i);
R[p[i]]=max(R[p[i]],i);
cnt[p[i]]++;
}
for(int i=1;i<=n;i++){
if(cnt[i]!=R[i]-L[i]+1)ans=0;
}
po[0]=1;
for(int i=1;i<=m;i++)po[i]=mul(po[i-1],2);
Solve(0,(1<<m)-1,m);
printf("%i\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3904kb
input:
4 12 2 2 3 6 1 12 1 12 9 7 5 5 4 8 10 11
output:
0
result:
wrong answer expected 8, found 0