QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#832493#4283. Power of XORpeimudaWA 660ms44668kbC++111.6kb2024-12-25 22:04:522024-12-25 22:04:52

Judging History

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

  • [2024-12-25 22:04:52]
  • 评测
  • 测评结果:WA
  • 用时:660ms
  • 内存:44668kb
  • [2024-12-25 22:04:52]
  • 提交

answer

#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#define pr pair
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pll pr<ll,ll>
#define pii pr<int,int>
#define piii pr<int,pii>
using namespace std;
const ll m=1e9+7;
ll vl[44];
bool hd[44];
int cnt=0;
void add(ll x)
{
	for(int i=43;i>=0;i--)
	{
		if(x&1ll<<i)
		{
			if(hd[i]) x^=vl[i];
			else
			{
				vl[i]=x;
				hd[i]=1;
				cnt++;
				return;
			}
		}
	}
}
ll pw(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b&1) r=r*a%m;
		a=a*a%m;
		b>>=1;
	}
	return r;
}
ll a[44];
int tv[1<<19][20];
int tx[20];
int ty[20];
ll ans[45];
int main()
{
	ios_base::sync_with_stdio(0);
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i],add(a[i]);
	ll tot=0;
	for(int i=0;i<1<<19;i++)
	{
		int fd=0;
		bool bd=0;
		for(int j=0;j<19;j++)
		{
			if(i&1<<j)
			{
				if(!hd[j]) bd=1;
				fd^=vl[j];
			}
		}
		if(bd) continue;
		tv[fd][0]++;
	}
	for(int i=0;i<19;i++) for(int j=0;j<1<<19;j++) if(j&1<<i)
	{
		int tj=j^1<<i;
		for(int k=0;k<=19;k++) tx[k]=tv[tj][k],ty[k]=tv[j][k];
		for(int k=1;k<=19;k++) tx[k]+=tv[j][k-1],ty[k]+=tv[tj][k-1];
		for(int k=0;k<=19;k++) tv[tj][k]=tx[k],tv[j][k]=ty[k];
	}
//	cerr<<"?"<<endl;
	for(int i=0;i<1<<23;i++)
	{
//		if(i%1000==0) cout<<"F "<<i<<endl;
		ll fd=0;
		bool bd=0;
		for(int j=0;j<23;j++)
		{
			if(i&1<<j)
			{
				if(!hd[j+19]) bd=1;
				fd^=vl[j+19];
			}
		}
		if(bd) continue;
		int ah=0;
		for(int j=19;j<44;j++) if(fd&1ll<<j) ah++;
		int r=fd%(1<<19);
		for(int j=0;j<=19;j++) ans[ah+j]+=tv[r][j];
	}
	for(int i=0;i<=44;i++) tot+=ans[i]%m*pw(i,k)%m;
	cout<<tot%m*pw(2,n-cnt)%m;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 644ms
memory: 44592kb

input:

3 2
1 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 651ms
memory: 44604kb

input:

2 1000000000
1 2

output:

140625003

result:

ok 1 number(s): "140625003"

Test #3:

score: 0
Accepted
time: 653ms
memory: 44664kb

input:

3 4
21 31 15

output:

1076

result:

ok 1 number(s): "1076"

Test #4:

score: 0
Accepted
time: 660ms
memory: 44660kb

input:

4 10
21 16 23 30

output:

3504120

result:

ok 1 number(s): "3504120"

Test #5:

score: 0
Accepted
time: 642ms
memory: 44532kb

input:

5 795325759
23 18 18 15 24

output:

398580583

result:

ok 1 number(s): "398580583"

Test #6:

score: -100
Wrong Answer
time: 655ms
memory: 44668kb

input:

6 425010546
15190825693299 11021868218180 10853490476696 16489831131502 15731786397897 1859285400474

output:

110691966

result:

wrong answer 1st numbers differ - expected: '226806798', found: '110691966'