QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#479394#7748. Karshilov's Matching Problem IIucup-team052#WA 2ms7668kbC++142.2kb2024-07-15 17:05:572024-07-15 17:05:58

Judging History

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

  • [2024-08-25 20:42:18]
  • hack成功,自动添加数据
  • (/hack/789)
  • [2024-07-15 17:05:58]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7668kb
  • [2024-07-15 17:05:57]
  • 提交

answer

#include <bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;

int read()
{
	int x; scanf("%d",&x);
	return x;
}
const int P=998244353;
int ad(int k1,int k2){return k1+k2>=P?k1+k2-P:k1+k2;}
int su(int k1,int k2){return k1-k2<0?k1-k2+P:k1-k2;}
int mu(int k1,int k2){return 1ULL*k1*k2%P;}
void uad(int&k1,int k2){(k1+=k2)>=P&&(k1-=P);}
void usu(int&k1,int k2){(k1-=k2)<0&&(k1+=P);}
template<class... T>int ad(int k1,T... k2){return ad(k1,ad(k2...));}
template<class... T>int su(int k1,T... k2){return su(k1,ad(k2...));}
template<class... T>int mu(int k1,T... k2){return mu(k1,mu(k2...));}
template<class... T>void uad(int&k1,T... k2){return uad(k1,ad(k2...));}
template<class... T>void usu(int&k1,T... k2){return usu(k1,ad(k2...));}
int po(int k1,int k2){
	int k3=1;
	for(;k2;k2>>=1,k1=mu(k1,k1))if(k2&1)k3=mu(k3,k1);
	return k3;
}
#define inc(x,y) x=add(x,y)
#define N 12
int a[N],b[N],f[1<<N][1005],g[1<<N][1005],fac[1005],ifac[1005],inv[1005];
int C[1005][1005],sum[1<<N],n,m;
signed main() {
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	fac[0]=1;
	rep(i,1,1004)fac[i]=mu(fac[i-1],i);
	ifac[1004]=po(fac[1004],P-2);
	per(i,1004,1)ifac[i-1]=mu(ifac[i],i);
	rep(i,1,1004)inv[i]=po(i,P-2);
	cin>>n>>m;
	for(int i=0;i<m;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	C[0][0]=1;
	for(int i=1;i<=1000;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=ad(C[i-1][j],C[i-1][j-1]);
	}
	f[0][0]=1;
	for(int i=0;i<1<<m;i++)
	{
		for(int j=0;j<m;j++) if(i>>j&1) sum[i]+=b[j];
	}
	for(int st=0;st<(1<<m);st++)
	{
		for(int i=0;i<=n;i++) if(f[st][i]||g[st][i])
		{
			if(st<(1<<m)-1){
				uad(f[st][i+1],f[st][i]);
				uad(g[st][i+1],g[st][i]);
				uad(g[st][i+1],mu(f[st][i],n,inv[n-__builtin_popcount(st)]));
			}
			rep(j,0,m-1)if((~st>>j&1)&&i>=b[j]-1){
				uad(f[st^(1<<j)][i-(b[j]-1)],mu(f[st][i],C[i][b[j]-1]));
				uad(g[st^(1<<j)][i-(b[j]-1)],mu(g[st^(1<<j)][i],C[i][b[j]-1]));
				uad(g[st^(1<<j)][i-(b[j]-1)],mu(f[st][i],C[i][b[j]-1],n,inv[n-__builtin_popcount(st)]));
			}
		}
	}
	printf("%d\n",g[(1<<m)-1][0]);
	return 0;
}

詳細信息

Test #1:

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

input:

8 5
abbabaab
aababbab
1 2 4 8 16 32 64 128
1 1
2 3
3 5
4 7
1 8

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'