QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106578#5827. 异或图sichengzhou0 2ms4560kbC++143.0kb2023-05-18 07:21:082023-05-18 07:21:09

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-18 07:21:09]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:4560kb
  • [2023-05-18 07:21:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=15,mod=998244353;
int n,m;
LL C,a[N],c[1<<N],f[1<<N],cnt1[1<<N];
int mi[1<<N];
bool e[1<<N];
vector<pair<int,LL> >dp[1<<N];
int lowbit(int x)
{
	return x&(-x);
}
LL ny[N<<2];
LL solve(int x)
{
	LL ret=0;
	bool extra=true;
	for(int j=59;j>=0;j--)
	{
		bool v=C>>j&1;
		for(int i=0;i<n;i++)
		{
			v^=(a[i]>>j&1);
		}
		LL m=1,m0=1,m1=0;
	    for(int i=0;i<n;i++)
	    {
	    	if(x>>i&1)
	    	{
	    		LL x=a[i]%(1ll<<j)+1,y=1ll<<j;
	    		m*=x;m%=mod;
	    		LL n0=m0,n1=m1;
	    		m0*=x;m0%=mod;
	    		m1*=x;m1%=mod;
	    		if(a[i]>>j&1)
	    		{
	    			m1+=n0*y%mod;m1%=mod;
	    			m0+=n1*y%mod;m0%=mod;
				}
			}
		}
	//	cout<<j<<' '<<ret<<' '<<m<<' '<<m0<<' '<<m1<<endl;
		if(v)
		{
			ret+=m1*ny[j]%mod;
			ret%=mod;
			extra=false;
			break;
		}else{
			ret+=(m0-m+mod)*ny[j]%mod;
			ret%=mod;
		}
	}
	if(extra)
	{
		ret=(ret+1)%mod;
	}
//	cout<<x<<"->"<<ret<<endl;
	return ret;
}
int main()
{
	LL ans=0;
	int u,v;
	scanf("%d%d%lld",&n,&m,&C);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	ny[0]=1;
	for(int i=1;i<=59;i++)
	{
		ny[i]=ny[i-1]*(mod+1)/2%mod;
	}
	printf("%lld\n",solve((1<<n)-1));
	return 0;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		u--;v--;
		e[(1<<u)+(1<<v)]=1;
	}
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;;j=(j/lowbit(i-j)+1)*lowbit(i-j))
		{
			e[i]|=e[j];
			if(j==i)
			{
				break;
			}
		}
	}
	for(int i=0;i<(1<<n);i++)
	{
		c[i]=1-e[i];
		int l=i-lowbit(i);
		for(int j=0;j<l;j=(j/lowbit(l-j)+1)*lowbit(l-j))
		{
			c[i]-=c[j+lowbit(i)]*(1-e[l-j])-mod;
			c[i]%=mod;
		}
	//	printf("c[%d]=%lld\n",i,c[i]);
	}
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i>>j&1)
			{
				continue;
			}
			cnt1[i+(1<<j)]=cnt1[i]+1;
			if(i==0)
			{
				mi[i+(1<<j)]=j;
			}else{
				if(a[mi[i]]<a[j])
				{
					mi[i+(1<<j)]=mi[i];
				}else{
					mi[i+(1<<j)]=j;
				}
			}
		}
	}
	dp[0].push_back(make_pair(0,1));
	for(int i=1;i<(1<<n);i++)
	{
		for(int j=0;j<=i;j++)
		{
			f[j]=0;
		}
		int l=i-lowbit(i);
	//	cout<<i<<endl;
		for(int j=0;j<=l;j=(j/lowbit(l-j)+1)*lowbit(l-j))
		{
			for(int k=0;k<dp[j].size();k++)
			{
				int x=dp[j][k].first;
				LL y=dp[j][k].second;
			//	cout<<x<<'*'<<y<<endl;
				if(cnt1[i-j]&1)
				{
					f[x+(1<<mi[i-j])]+=y*c[i-j]%mod;
					f[x+(1<<mi[i-j])]%=mod;
				}else{
				//	cout<<"**";
					f[x]+=y*c[i-j]%mod*(a[mi[i-j]]+1)%mod;
					f[x]%=mod;
				}
			//	cout<<f[x]<<endl;
			}
			if(j==l)
			{
				break;
			}
		}
	//	cout<<i<<endl;
		for(int j=0;j<=i;j++)
		{
			if(f[j])
			{
			//	cout<<j<<' '<<f[j]<<endl;
				dp[i].push_back(make_pair(j,f[j]));
			}
		}
	//	cout<<endl;
	}
	for(int i=0;i<dp[(1<<n)-1].size();i++)
	{
		int x=dp[(1<<n)-1][i].first;
		LL y=dp[(1<<n)-1][i].second;
	//	cout<<y<<endl;
		ans+=y*solve(x)%mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 4364kb

input:

4 6 2
7 11 14 0
1 2
1 3
2 3
2 4
4 1
4 3

output:

92

result:

wrong answer 1st numbers differ - expected: '44', found: '92'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #47:

score: 0
Wrong Answer
time: 2ms
memory: 4560kb

input:

14 0 731833687287532167
157552918690640051 900457311668526045 111217720157614956 84140984111060473 814012186135880499 784848789620248379 958953377683017264 105083874298571687 104921429970878846 44983041675142735 871013110538758030 686733907990421995 98063590462078176 495161493555059993

output:

726673955

result:

wrong answer 1st numbers differ - expected: '231790380', found: '726673955'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%