QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#828466#4283. Power of XORInvincibleWA 1ms6108kbC++232.4kb2024-12-23 16:52:082024-12-23 16:52:16

Judging History

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

  • [2024-12-23 16:52:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6108kb
  • [2024-12-23 16:52:08]
  • 提交

answer

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <ctime>
#include <random>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#define pii pair<int, int>
#define fi first
#define se second
#define MP make_pair
#define ep emplace
#define eb emplace_back
#define int long long
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
typedef double db;
typedef long double ldb;
typedef long long ll;
//typedef __int128 lll;
typedef unsigned long long ull;
typedef unsigned int ui;
using namespace std;
using namespace __gnu_pbds;
bool Mbe;

//char buf[1<<20],*p1,*p2;
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin), p1 == p2) ? 0 : *p1++)
int read() {
	int s = 0, f = 1;
	char c = getchar();
	while (c < '0' || c > '9') f ^= (c == '-'), c = getchar();
	while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
	return f ? s : -s;
}
template<typename T>void chkmax(T&x,const T&y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,const T&y){if(x>y)x=y;}

const int mod=1e9+7;
int fpow(int x,int k){
	int res=1;
	for(;k;k>>=1){
		if(k&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
int n,k,a[45],val[1<<24],pw[45],b[45],ans,dp[45][1<<20];
int w[45];
bool insert(int x){
	per(i,43,0){
		if(x>>i&1){
			if(!w[i])return w[i]=x,1;
			x^=w[i];
		}
	}
	return 0;
}

bool Med;
signed main() {
	fprintf(stderr,"%.3lfMb\n",(&Mbe-&Med)/1024./1024.);
	n=read(),k=read();
	int cnt=0;
	rep(i,0,44)pw[i]=fpow(i,k);
	rep(i,0,n-1){
		if(insert(a[i]=read())){
			b[cnt++]=i;
		}
	}
	per(i,43,0)if(w[i])per(j,i+1,43)if(w[j]>>i&1)cout<<"WTF";
//		for(i=W-1;~i;--i) if(p[i]) for(j=i+1;j<W;++j) if((p[j]>>i)&1) p[j]^=p[i];
	if(cnt<=24){
		rep(S,1,(1<<cnt)-1){
			val[S]=val[S^(S&-S)]^a[b[__lg(S&-S)]];
			ans=(ans+pw[__builtin_popcountll(val[S])])%mod;
		}
	}else{
		int nn=(1ll<<(44-cnt))-1;
		dp[0][0]=1;
		rep(i,0,cnt-1){
			int sum=0;
			per(j,b[i],0)if(!w[j])sum=sum<<1|(w[b[i]]>>j&1);
			per(j,i,0)rep(S,0,nn)dp[j+1][S^sum]=(dp[j+1][S^sum]+dp[j][S])%mod;
		}
		rep(i,1,cnt)rep(S,0,nn)ans=(ans+dp[i][S]*pw[i+__builtin_popcountll(S)]);
	}
	ans=ans*fpow(2,n-cnt)%mod;
	printf("%lld\n",ans);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5760kb

input:

3 2
1 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 0ms
memory: 6048kb

input:

2 1000000000
1 2

output:

140625003

result:

ok 1 number(s): "140625003"

Test #3:

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

input:

3 4
21 31 15

output:

1076

result:

ok 1 number(s): "1076"

Test #4:

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

input:

4 10
21 16 23 30

output:

3504120

result:

ok 1 number(s): "3504120"

Test #5:

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

input:

5 795325759
23 18 18 15 24

output:

398580583

result:

ok 1 number(s): "398580583"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 6016kb

input:

6 425010546
15190825693299 11021868218180 10853490476696 16489831131502 15731786397897 1859285400474

output:

WTFWTF226806798

result:

wrong output format Expected integer, but "WTFWTF226806798" found