QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659815#5169. 夹娃娃QBFCompile Error//C++146.8kb2024-10-19 22:15:242024-10-19 22:15:25

Judging History

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

  • [2024-10-19 22:15:25]
  • 评测
  • [2024-10-19 22:15:24]
  • 提交

answer

#include<bits/stdc++.h>
#define ci const int
#define ll long long
using namespace std;
char buf[1<<20],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
int read(){int res(0);char ch(getchar());while(ch<48||ch>57)ch=getchar();while(ch>=48&&ch<=57)res=(res<<1)+(res<<3)+(ch^48),ch=getchar();return res;}
void out(ci x){
	if(x>9)out(x/10);
	putchar(x%10+48);
}
int n,q;
namespace sol1{
	ci mod=998244353,V=520,M=2080;
	inline void add(int &x,ci v){
		x+=v,x-=x<mod?0:mod;
	}
	inline void sub(int &x,ci v){
		x-=v,x+=x<0?mod:0;
	}
	ll qk(ll x,int y=mod-2){
		ll ans=1;
		while(y){
			if(y&1)ans=ans*x%mod;
			x=x*x%mod,y>>=1;
		}
		return ans;
	}
	int cnt[1<<15];
	int co[16][525];
	int pw[2100][525];
	struct DAT{
		int co[6][525];
		int val[6][525][2100];//val[i][<=k]
		int g[525][1<<5][2100];//g[k][s]
		int f[1<<5][2100],F[1<<5][525];//f[s]
		void Solve(){
			for(int i=1;i<=5;++i)
				for(int x=1;x<=M;++x)
					for(int j=0;j<=V;++j)
						val[i][j][x]=((ll)pw[x][j]*co[i][j]+(j?val[i][j-1][x]:0))%mod;
			F[0][0]=1;
			for(int s=1;s<1<<5;++s){
				ci b=__builtin_ctz(s&-s)+1;
				for(int i=0;i<=V;++i)
					for(int j=0;i+j<=V;++j)
						add(F[s][i+j],(ll)F[s^(s&-s)][i]*co[b][j]%mod);
			}
			for(int s=0;s<1<<5;++s)
				for(int x=1;x<=M;++x)
					for(int j=0;j<=V;++j)
						add(f[s][x],(ll)F[s][j]*pw[x][j]%mod);
			for(int k=1;k<=V;++k){
				for(int x=1;x<=M;++x)g[k][0][x]=1;
				for(int s=1;s<1<<5;++s){
					if(cnt[s]*k>V)continue;
					ci sv=s&-s;
					ci b=__builtin_ctz(sv)+1;
					for(int x=1;x<=M;++x)
						g[k][s][x]=mod-(ll)g[k][s^sv][x]*val[b][k-1][x]%mod;
				}
				for(int s=0;s<1<<5;++s)
					for(int x=1;x<=M;++x)
						g[k][s][x]=(ll)g[k][s][x]*f[s^31][x]%mod;
				for(int i=1;i<=5;++i)
					for(int s=0;s<1<<5;++s)
						if(s>>(i-1)&1)
							for(int x=1;x<=M;++x)
								add(g[k][s][x],g[k][s^(1<<i-1)][x]);
			}
		}
	}DL,DM,DR;
	int la[2100][2100],poly[2100],tmp[2100];
	int main(){
		for(int i=1;i<=15;++i)co[i][0]=1;
		for(int i=1;i<=n;++i){
			for(int k=read();k;--k){
				ci b=read(),c=read();
				for(int j=b;j<=V;++j)add(co[i][j],co[i][j-b]);
				for(int j=V;~j;--j)co[i][j]=(co[i][j]-(j>=(c+1)*b?co[i][j-(c+1)*b]:0)+mod)%mod;
			}
		}
		for(int s=0;s<1<<15;++s)cnt[s]=cnt[s>>1]+(s&1);
		for(int x=1;x<=M;++x){
			pw[x][0]=1;
			for(int i=1;i<=V;++i)pw[x][i]=(ll)pw[x][i-1]*x%mod;
		}
		for(int i=1;i<=5;++i)
			for(int j=0;j<=V;++j)
				DL.co[i][j]=co[i][j],
				DM.co[i][j]=co[i+5][j],
				DR.co[i][j]=co[i+10][j];
		DL.Solve(),DM.Solve(),DR.Solve();
		poly[0]=1;
		for(int i=1;i<=M;++i)
			for(int j=M;~j;--j)
				poly[j]=((j?poly[j-1]:0)-(ll)i*poly[j]%mod+mod)%mod;
		for(int i=1;i<=M;++i){
			for(int j=0;j<=M;++j)tmp[j]=poly[j];
			for(int j=M;j;--j)la[i][j-1]=tmp[j],add(tmp[j-1],(ll)tmp[j]*i%mod);
			int co=1;
			for(int j=1;j<=M;++j)if(i!=j)co=(ll)co*(i-j+mod)%mod;
			co=qk(co);
			for(int j=0;j<=M;++j)la[i][j]=(ll)la[i][j]*co%mod;
			for(int j=1;j<=M;++j)add(la[i][j],la[i][j-1]);
		}
		while(q--){
			int s1=0,s2=0,s3=0;
			for(int i=1;i<=n;++i){
				char c=getchar();
				while(c!='0'&&c!='1')c=getchar();
				if(c=='1'){
					if(i<=5)s1|=1<<i-1;
					else if(i<=10)s2|=1<<i-5-1;
					else s3|=1<<i-10-1;
				}
			}
			ci m=read(),k=read();
			if((cnt[s1]+cnt[s2]+cnt[s3])*k>m){
				puts("0");
				continue;
			}
			__uint128_t ans=0;
			for(int x=1;x<=M;++x){
				ans+=(__uint128_t)DL.g[k][s1][x]*DM.g[k][s2][x]*DR.g[k][s3][x]*la[x][m];
				if((x&127)==0||x==M)ans%=mod;
			}
			out(ans%mod),putchar(10);
		}
		return 0;
	}
}
namespace sol1{
	ci mod=1e9+7,V=520,M=2080;
	inline void add(int &x,ci v){
		x+=v,x-=x<mod?0:mod;
	}
	inline void sub(int &x,ci v){
		x-=v,x+=x<0?mod:0;
	}
	ll qk(ll x,int y=mod-2){
		ll ans=1;
		while(y){
			if(y&1)ans=ans*x%mod;
			x=x*x%mod,y>>=1;
		}
		return ans;
	}
	int cnt[1<<15];
	int co[16][525];
	int pw[2100][525];
	struct DAT{
		int co[6][525];
		int val[6][525][2100];//val[i][<=k]
		int g[525][1<<5][2100];//g[k][s]
		int f[1<<5][2100],F[1<<5][525];//f[s]
		void Solve(){
			for(int i=1;i<=5;++i)
				for(int x=1;x<=M;++x)
					for(int j=0;j<=V;++j)
						val[i][j][x]=((ll)pw[x][j]*co[i][j]+(j?val[i][j-1][x]:0))%mod;
			F[0][0]=1;
			for(int s=1;s<1<<5;++s){
				ci b=__builtin_ctz(s&-s)+1;
				for(int i=0;i<=V;++i)
					for(int j=0;i+j<=V;++j)
						add(F[s][i+j],(ll)F[s^(s&-s)][i]*co[b][j]%mod);
			}
			for(int s=0;s<1<<5;++s)
				for(int x=1;x<=M;++x)
					for(int j=0;j<=V;++j)
						add(f[s][x],(ll)F[s][j]*pw[x][j]%mod);
			for(int k=1;k<=V;++k){
				for(int x=1;x<=M;++x)g[k][0][x]=1;
				for(int s=1;s<1<<5;++s){
					if(cnt[s]*k>V)continue;
					ci sv=s&-s;
					ci b=__builtin_ctz(sv)+1;
					for(int x=1;x<=M;++x)
						g[k][s][x]=mod-(ll)g[k][s^sv][x]*val[b][k-1][x]%mod;
				}
				for(int s=0;s<1<<5;++s)
					for(int x=1;x<=M;++x)
						g[k][s][x]=(ll)g[k][s][x]*f[s^31][x]%mod;
				for(int i=1;i<=5;++i)
					for(int s=0;s<1<<5;++s)
						if(s>>(i-1)&1)
							for(int x=1;x<=M;++x)
								add(g[k][s][x],g[k][s^(1<<i-1)][x]);
			}
		}
	}DL,DM,DR;
	int la[2100][2100],poly[2100],tmp[2100];
	int main(){
		for(int i=1;i<=15;++i)co[i][0]=1;
		for(int i=1;i<=n;++i){
			for(int k=read();k;--k){
				ci b=read(),c=read();
				for(int j=b;j<=V;++j)add(co[i][j],co[i][j-b]);
				for(int j=V;~j;--j)co[i][j]=(co[i][j]-(j>=(c+1)*b?co[i][j-(c+1)*b]:0)+mod)%mod;
			}
		}
		for(int s=0;s<1<<15;++s)cnt[s]=cnt[s>>1]+(s&1);
		for(int x=1;x<=M;++x){
			pw[x][0]=1;
			for(int i=1;i<=V;++i)pw[x][i]=(ll)pw[x][i-1]*x%mod;
		}
		for(int i=1;i<=5;++i)
			for(int j=0;j<=V;++j)
				DL.co[i][j]=co[i][j],
				DM.co[i][j]=co[i+5][j],
				DR.co[i][j]=co[i+10][j];
		DL.Solve(),DM.Solve(),DR.Solve();
		poly[0]=1;
		for(int i=1;i<=M;++i)
			for(int j=M;~j;--j)
				poly[j]=((j?poly[j-1]:0)-(ll)i*poly[j]%mod+mod)%mod;
		for(int i=1;i<=M;++i){
			for(int j=0;j<=M;++j)tmp[j]=poly[j];
			for(int j=M;j;--j)la[i][j-1]=tmp[j],add(tmp[j-1],(ll)tmp[j]*i%mod);
			int co=1;
			for(int j=1;j<=M;++j)if(i!=j)co=(ll)co*(i-j+mod)%mod;
			co=qk(co);
			for(int j=0;j<=M;++j)la[i][j]=(ll)la[i][j]*co%mod;
			for(int j=1;j<=M;++j)add(la[i][j],la[i][j-1]);
		}
		while(q--){
			int s1=0,s2=0,s3=0;
			for(int i=1;i<=n;++i){
				char c=getchar();
				while(c!='0'&&c!='1')c=getchar();
				if(c=='1'){
					if(i<=5)s1|=1<<i-1;
					else if(i<=10)s2|=1<<i-5-1;
					else s3|=1<<i-10-1;
				}
			}
			ci m=read(),k=read();
			if((cnt[s1]+cnt[s2]+cnt[s3])*k>m){
				puts("0");
				continue;
			}
			__uint128_t ans=0;
			for(int x=1;x<=M;++x){
				ans+=(__uint128_t)DL.g[k][s1][x]*DM.g[k][s2][x]*DR.g[k][s3][x]*la[x][m];
				if((x&127)==0||x==M)ans%=mod;
			}
			out(ans%mod),putchar(10);
		}
		return 0;
	}
}
int main(){
	n=read(),q=read();
	if(read()==998244353)return sol1::main();
	else return sol2::main();
}

詳細信息

answer.code:134:12: error: redefinition of ‘const int sol1::mod’
  134 |         ci mod=1e9+7,V=520,M=2080;
      |            ^~~
answer.code:14:12: note: ‘const int sol1::mod’ previously defined here
   14 |         ci mod=998244353,V=520,M=2080;
      |            ^~~
answer.code:134:22: error: redefinition of ‘const int sol1::V’
  134 |         ci mod=1e9+7,V=520,M=2080;
      |                      ^
answer.code:14:26: note: ‘const int sol1::V’ previously defined here
   14 |         ci mod=998244353,V=520,M=2080;
      |                          ^
answer.code:134:28: error: redefinition of ‘const int sol1::M’
  134 |         ci mod=1e9+7,V=520,M=2080;
      |                            ^
answer.code:14:32: note: ‘const int sol1::M’ previously defined here
   14 |         ci mod=998244353,V=520,M=2080;
      |                                ^
answer.code:135:21: error: redefinition of ‘void sol1::add(int&, int)’
  135 |         inline void add(int &x,ci v){
      |                     ^~~
answer.code:15:21: note: ‘void sol1::add(int&, int)’ previously defined here
   15 |         inline void add(int &x,ci v){
      |                     ^~~
answer.code:138:21: error: redefinition of ‘void sol1::sub(int&, int)’
  138 |         inline void sub(int &x,ci v){
      |                     ^~~
answer.code:18:21: note: ‘void sol1::sub(int&, int)’ previously defined here
   18 |         inline void sub(int &x,ci v){
      |                     ^~~
answer.code:141:12: error: redefinition of ‘long long int sol1::qk(long long int, int)’
  141 |         ll qk(ll x,int y=mod-2){
      |            ^~
answer.code:21:12: note: ‘long long int sol1::qk(long long int, int)’ previously defined here
   21 |         ll qk(ll x,int y=mod-2){
      |            ^~
answer.code:149:13: error: redefinition of ‘int sol1::cnt [32768]’
  149 |         int cnt[1<<15];
      |             ^~~
answer.code:29:13: note: ‘int sol1::cnt [32768]’ previously declared here
   29 |         int cnt[1<<15];
      |             ^~~
answer.code:150:13: error: redefinition of ‘int sol1::co [16][525]’
  150 |         int co[16][525];
      |             ^~
answer.code:30:13: note: ‘int sol1::co [16][525]’ previously declared here
   30 |         int co[16][525];
      |             ^~
answer.code:151:13: error: redefinition of ‘int sol1::pw [2100][525]’
  151 |         int pw[2100][525];
      |             ^~
answer.code:31:13: note: ‘int sol1::pw [2100][525]’ previously declared here
   31 |         int pw[2100][525];
      |             ^~
answer.code:152:16: error: redefinition of ‘struct sol1::DAT’
  152 |         struct DAT{
      |                ^~~
answer.code:32:16: note: previous definition of ‘struct sol1::DAT’
   32 |         struct DAT{
      |                ^~~
answer.code:192:10: error: conflicting declaration ‘int sol1::DL’
  192 |         }DL,DM,DR;
      |          ^~
answer.code:72:10: note: previous declaration as ‘sol1::DAT sol1::DL’
   72 |         }DL,DM,DR;
      |          ^~
answer.code:192:13: error: conflicting declaration ‘int sol1::DM’
  192 |         }DL,DM,DR;
      |             ^~
answer.code:72:13: note: previous declaration as ‘sol1::DAT sol1::DM’
   72 |         }DL,DM,DR;
      |             ^~
answer.code:192:16: error: conflicting declaration ‘int sol1::DR’
  192 |         }DL,DM,DR;
      |                ^~
answer.code:72:16: note: previous declaration as ‘sol1::DAT sol1::DR’
   72 |         }DL,DM,DR;
      |                ^~
answer.code:193:13: error: redefinition of ‘int sol1::la [2100][2100]’
  193 |         int la[2100][2100],poly[2100],tmp[2100];
      |             ^~
answer.code:73:13: note: ‘int sol1::la [2100][2100]’ previously declared here
   73 |         int la[2100][2100],poly[2100],tmp[2100];
      |             ^~
answer.code:193:28: error: redefinition of ‘int sol1::poly [2100]’
  193 |         int la[2100][2100],poly[2100],tmp[2100];
      |                            ^~~~
answer.code:73:28: note: ‘int sol1::poly [2100]’ previously declared here
   73 |         int la[2100][2100],poly[2100],tmp[2100];
      |                            ^~~~
answer.code:193:39: error: redefinition of ‘int sol1::tmp [2100]’
  193 |         int la[2100][2100],poly[2100],tmp[2100];
      |                                       ^~~
answer.code:73:39: note: ‘int sol1::tmp [2100]’ previously declared here
   73 |         int la[2100][2100],poly[2100],tmp[2100];
      |                                       ^~~
answer.code:194:13: error: redefinition of ‘int sol1::main()’
  194 |         int main(){
      |             ^~~~
answer.code:74:13: note: ‘int sol1::main()’ previously defined here
   74 |         int main(){
      |             ^~~~
answer.code: In function ‘int main()’:
answer.code:256:21: error: ‘sol2’ has not been declared
  256 |         else return sol2::main();
      |                     ^~~~