QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#387742#5019. 整数jinqihao2023Compile Error//C++142.2kb2024-04-12 19:09:422024-04-12 19:09:42

Judging History

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

  • [2024-04-12 19:09:42]
  • 评测
  • [2024-04-12 19:09:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=19,M=(1<<18)+5,K=65,mod=998244353;
typedef long long ll;
int n,s[M],f[K][M],to[N],pr[N],g[M],h[M],all,ito[N];
ll lim[N];
int getc()
{
	char ch=getchar();
	while(ch!='0' && ch!='1')ch=getchar();
	return ch-'0';
}
inline void add(int &x,int y){x+=y;if(x>=mod)x-=mod;}
inline int md(int x){if(x>=mod)x-=mod;return x;}
void fwt(int *temp,int len)
{
	for(int i=1;i<(1<<len);i<<=1)
	{
		for(int j=0;j<(1<<len);j+=(i<<1))
		{
			for(int k=0;k<i;k++)
			{
				int x=temp[j+k],y=temp[i+j+k];
				temp[j+k]=y,temp[i+j+k]=md(x+y);
			}
		}
	}
}
void ifwt(int *temp,int len)
{
	for(int i=1;i<(1<<len);i<<=1)
	{
		for(int j=0;j<(1<<len);j+=(i<<1))
		{
			for(int k=0;k<i;k++)
			{
				int x=temp[j+k],y=temp[i+j+k];
				temp[j+k]=md(y-x+mod),temp[i+j+k]=x;
			}
		}
	}
}
int trans(int x)
{
	int res=0;
	for(int i=0;i<n;i++)if((x>>i)&1)res|=(1<<to[i]);
	return res;
}
int itrans(int x)
{
	int res=0;
	for(int i=0;i<n;i++)if((x>>i)&1)res|=(1<<ito[i]);
	return res;
}
int a[M],b[M],temp[M];
int main()
{
	scanf("%d",&n),all=(1<<n)-1;
	for(int i=0;i<n;i++)scanf("%lld",&lim[i]);
	for(int i=0;i<(1<<n);i++)s[i]=getc();
	f[60][(1<<n)-1]=1;
	for(int i=60;i>=1;i--)
	{
		int p=0,now=0,p1=0;
		for(int j=0;j<n;j++)if((lim[j]>>i-1)&1)now|=(1<<j);
		for(int j=0;j<n;j++)if(((now>>j)&1)^1)to[j]=p,ito[p]=j,p++,p1++;
		for(int j=0;j<n;j++)if((now>>j)&1)to[j]=p1,ito[p1]=j,p1++;
		for(int j=0;j<(1<<n);j++)g[trans(j)]=s[j];
		for(int j=0;j<p;j++)
		{
			for(int k=0;k<(1<<n);k++)h[k]=0;
			for(int k=0;k<(1<<n);k++)
			{
				if((k>>j)&1)add((h[k^(1<<j)],g[k]);
				else add(h[k],g[k]),add(h[k^(1<<j)],g[k]);
			}
			for(int k=0;k<(1<<n);k++)g[k]=h[k];
		}
		int q=n-p;
		for(int j=0;j<(1<<p);j++)
		{
			for(int k=0;k<(1<<q);k++)a[k]=f[i][itrans((k<<p)^j)],b[k]=g[(k<<p)^j];
			fwt(a,q),fwt(b,q);
			for(int k=0;k<(1<<q);k++)a[k]=1ll*a[k]*b[k]%mod;
			ifwt(a,q);
			for(int k=0;k<(1<<q);k++)f[i-1][(k<<p)^j]=a[k];
		}
		for(int j=0;j<(1<<n);j++)temp[j]=f[i-1][trans(j)];
		for(int j=0;j<(1<<n);j++)f[i-1][j]=temp[j];
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++)ans=(ans+f[0][i])%mod;
	printf("%d\n",ans);
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:74:67: error: expected ‘)’ before ‘;’ token
   74 |                                 if((k>>j)&1)add((h[k^(1<<j)],g[k]);
      |                                                ~                  ^
      |                                                                   )
answer.code:58:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   58 |         scanf("%d",&n),all=(1<<n)-1;
      |         ~~~~~^~~~~~~~~
answer.code:59:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   59 |         for(int i=0;i<n;i++)scanf("%lld",&lim[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~