QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#82868#5408. 计数鸡zhouhuanyi0 2ms3676kbC++231.5kb2023-02-28 22:48:042023-02-28 22:48:05

Judging History

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

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

answer

#include<iostream>
#include<cstdio>
#define N 300
#define mod 998244353
using namespace std;
int read()
{
    char c=0;
    int sum=0,f=1;
    while (c!='-'&&(c<'0'||c>'9')) c=getchar();
    if (c=='-') c=getchar(),f=-1;
    while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
    return sum*f;
}
int MD(int x)
{
    return x>=mod?x-mod:x;
}
int MD2(int x)
{
    return x<0?x+mod:x;
}
void Adder2(int &x,int d)
{
    x+=d;
    if (x<0) x+=mod;
    return;
}
int fast_pow(int a,int b)
{
    int res=1,mul=a;
    while (b)
    {
	if (b&1) res=1ll*res*mul%mod;
	mul=1ll*mul*mul%mod,b>>=1;
    }
    return res;
}
int n,inv2,h[N+1],q[N+1],G[N+1][N+1];
int gauss()
{
    int d,res=1;
    for (int i=1;i<=n;++i)
    {
	for (int j=1;j<=n;++j)
	    if (!G[i][i]&&G[j][i]&&(j>i||!G[j][j]))
		swap(G[i],G[j]);
	if (G[i][i])
	{
	    for (int j=i+1;j<=n;++j)
	    {
		d=1ll*G[j][i]*fast_pow(G[i][i],mod-2)%mod;
		for (int k=i;k<=n;++k) Adder2(G[j][k],-1ll*G[i][k]*d%mod);
	    }
	}
    }
    for (int i=1;i<=n;++i) res=1ll*res*G[i][i]%mod;
    return res;
}
int main()
{
    int res=1;
    n=read(),inv2=(mod+1)>>1;
    for (int i=1;i<=n;++i) q[i]=read(),res=1ll*res*i%mod;
    for (int i=1;i<=n;++i) h[i]=read();
    for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j)
	{
	    G[i][j]=1;
	    for (int k=i+1;k<=n;++k)
		if (j+h[i]>=q[k])
		    G[i][j]=MD2(-G[i][j]);
	}
    printf("%lld\n",1ll*MD(res+gauss())*inv2%mod);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 2ms
memory: 3464kb

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: 2ms
memory: 3512kb

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: 2ms
memory: 3460kb

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: 2ms
memory: 3676kb

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%