QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#823060#4283. Power of XORcwfxlhWA 2ms7696kbC++141.9kb2024-12-20 18:45:162024-12-20 18:45:18

Judging History

This is the latest submission verdict.

  • [2024-12-20 18:45:18]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 7696kb
  • [2024-12-20 18:45:16]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;
int n,k,a[503],xxj[503],apr[503],ans,cnt,cnt2,C[503][503],f[503],f2[45][(1<<20)],renum[503],idx;
int v1[503],tot;
int fstp(int X,int Y){int ret=1,bse=X%MOD;while(Y){if(Y%2)ret=ret*bse%MOD;bse=bse*bse%MOD;Y/=2;}return ret;}
int ppcnt(int X){
	if(X==0)return 0;
	if(X%2==1)return ppcnt(X/2)+1;
	return ppcnt(X/2);
}
signed main(){
	ios::sync_with_stdio(false);
	for(int i=0;i<=500;i++)C[i][0]=1;
	for(int i=1;i<=500;i++){
		for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
	}
	cin>>n>>k;
	for(int i=0;i<=50;i++)f[i]=fstp(i,k);
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		for(int j=0;j<44;j++){
			if((a[i]>>j)&1)apr[j]=1;
		}
		for(int j=43;j>=0;j--){
			if((a[i]>>j)&1){
				if(xxj[j]==0){
					xxj[j]=a[i];
					break;
				}
				else a[i]^=xxj[j];
			}
		}
	}
	for(int i=44;i>=0;i--){
		if(xxj[i]==0)continue;
		for(int j=i+1;j<=44;j++)if(((xxj[j]>>i)&1)!=0)xxj[j]^=xxj[i];
	}
	for(int i=0;i<=44;i++){
		if(xxj[i]!=0)v1[++tot]=xxj[i];
		else{
			if(apr[i]==0)continue;
			cnt++;
			cnt2|=(1<<i);
		}
	}
	if(tot<=24){
		for(int i=0;i<(1<<tot);i++){
			int u=0;
			for(int j=1;j<=tot;j++)if((i>>(j-1))&1)u^=v1[j];
			u|=cnt2;
			u=ppcnt(u);
			for(int j=0;j<=cnt;j++)ans=(ans+C[cnt][j]*f[u-j])%MOD;
		}
	}
	else{
		for(int i=0;i<=44;i++)if(xxj[i]==0)renum[i]=++idx;
		f2[0][0]=1;
		for(int i=0;i<=44;i++){
			if(xxj[i]==0)continue;
			int o=0;
			for(int j=0;j<=44;j++){
				if(xxj[i]==0&&((xxj[i]>>j)&1))o^=(1<<(renum[j]-1));
			}
			for(int u=43;u>=0;u--){
				for(int j=0;j<(1<<idx);j++){
					f2[u+1][j^o]=(f2[u+1][j^o]+f2[u][j])%MOD;
				}
			}
		}
		for(int i=0;i<=44;i++){
			for(int j=0;j<(1<<idx);j++)ans=(ans+f[ppcnt(j)+i]*f2[i][j])%MOD;
		}
	}
	for(int i=1;i<=n;i++)if(a[i]==0)ans=ans*2ll%MOD;
	ans%=MOD;
	ans+=MOD;
	ans%=MOD;
	cout<<ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6604kb

input:

3 2
1 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 1ms
memory: 6664kb

input:

2 1000000000
1 2

output:

140625003

result:

ok 1 number(s): "140625003"

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 7696kb

input:

3 4
21 31 15

output:

2880

result:

wrong answer 1st numbers differ - expected: '1076', found: '2880'