QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372041#3013. XOR SequencesInfinityNS#WA 1ms3896kbC++14876b2024-03-30 20:00:322024-03-30 20:00:34

Judging History

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

  • [2024-03-30 20:00:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3896kb
  • [2024-03-30 20:00:32]
  • 提交

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]);
		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;
}

详细

Test #1:

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

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