QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#82863 | #5408. 计数鸡 | zhouhuanyi | 0 | 2ms | 3712kb | C++23 | 1.3kb | 2023-02-28 22:40:20 | 2023-02-28 22:40:23 |
Judging History
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;
}
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;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][i]=(j+h[i]>=q[i])?mod-1:1;
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: 3680kb
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:
699910446
result:
wrong answer 1st numbers differ - expected: '694405422', found: '699910446'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 30
Accepted
time: 2ms
memory: 3712kb
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: 0ms
memory: 3512kb
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:
985377138
result:
wrong answer 1st numbers differ - expected: '985385330', found: '985377138'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%