QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226660#5408. 计数鸡xyz1230 11ms28596kbC++142.0kb2023-10-26 13:17:162023-10-26 13:17:16

Judging History

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

  • [2023-10-26 13:17:16]
  • 评测
  • 测评结果:0
  • 用时:11ms
  • 内存:28596kb
  • [2023-10-26 13:17:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long T,a,b,c,d[1000001],v[1000001],g[301][301],o,f[1000001],h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001];
char s[1000001];
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
int main()
{
//	freopen("1.in","r",stdin);
	srand((unsigned)(time(0)^(*new int)));
	fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
	inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	T=1;
//	scanf("%lld",&T);
	for(int ii=1;ii<=T;ii++)
	{
		scanf("%lld",&a);
		for(int i=1;i<=a;i++) scanf("%lld",&d[i]);
		for(int i=1;i<=a;i++) scanf("%lld",&f[i]);
		for(int i=1;i<=a;i++)
		{
			for(int j=1;j<=a;j++)
			{
				g[i][j]=1;
				for(int k=i+1;k<=a;k++) if(j+f[i]>=d[k]) g[i][j]*=-1;
			} 
		}
		an=1;
		for(int i=1;i<=a;i++)
		{
			long long tt=0;
			for(int j=i;j<=a;j++)
			{
				if(g[j][i])
				{
					tt=j;break;
				}
			}
			if(!tt){an=0;break;}
			for(int j=1;j<=a;j++) swap(g[i][j],g[tt][j]);
			for(int j=i+1;j<=a;j++)
			{
				long long gg=pow_(g[i][i],mod-2)%mod*g[j][i]%mod;
				for(int k=i;k<=a;k++) g[j][k]=(g[j][k]-g[i][k]*gg)%mod;
			}
		}
		for(int i=1;i<=a;i++) an=an*g[i][i]%mod;
		printf("%lld",((an+fac[a])%mod*pow_(2,mod-2)%mod+mod)%mod);
	}
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 4ms
memory: 26548kb

input:

20
20 4 15 16 11 3 7 18 9 5 13 8 6 12 2 10 1 17 14 19
-7 -11 9 -3 -20 -13 -18 15 0 8 0 12 -16 -19 8 -9 -4 -2 6 -10

output:

699910446

result:

ok 1 number(s): "699910446"

Test #2:

score: -20
Wrong Answer
time: 8ms
memory: 28596kb

input:

20
11 6 3 18 17 19 4 8 10 15 12 16 1 13 7 14 5 20 9 2
13 9 -1 1 9 -11 -19 8 -5 -11 -4 3 17 1 8 1 0 -11 -16 -10

output:

705415470

result:

wrong answer 1st numbers differ - expected: '694405422', found: '705415470'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 30
Accepted
time: 8ms
memory: 28536kb

input:

15
14 4 15 10 11 3 7 1 9 5 13 8 6 12 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

985377138

result:

ok 1 number(s): "985377138"

Test #12:

score: -30
Wrong Answer
time: 11ms
memory: 26332kb

input:

15
1 2 12 4 8 13 6 5 9 3 11 10 7 14 15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

985368946

result:

wrong answer 1st numbers differ - expected: '985385330', found: '985368946'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%