QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372812 | #7301. Even Three is Odd | D_F_S | WA | 3ms | 3932kb | C++14 | 1.2kb | 2024-03-31 19:29:25 | 2024-03-31 19:29:25 |
Judging History
answer
#include<bits/stdc++.h>
#define inl inline
#define CL(s) memset(s,0,sizeof(s))
using namespace std;
const int N=2005,P=998244353;
int n,x,y,an,w[N],s0[N],s1[N],s2[N],s3[N];
struct F {int a[N],b[N],c[N]; inl void G() {CL(a); CL(b); CL(c); } }f[2];
inl void Az(int &x,int y) {(x+=y)>=P&&(x-=P); }
int main()
{
for(;~scanf("%d",&n);printf("%d\n",an),an=0)
{
f[x=0].G(); y=1; for(int i=1;i<=n;++i)
{
scanf("%d",&w[i]);
f[0].a[i]=w[i], f[0].b[i]=(i-1ll)*w[i]%P, f[0].c[i]=(i-1ll)*(i-1)*w[i]%P;
}
for(int i=1;i<n-2;++i,x^=1,y^=1)
{
f[y].G(); CL(s0); CL(s1); CL(s2); CL(s3);
for(int j=1;j<=n;++j)
{
int t0=f[x].a[j],t1=f[x].b[j],t2=f[x].c[j];
Az(s0[j],t0); Az(s1[j],t0); Az(s2[1],t0); Az(s2[j+1],P-t0); s3[j+1]=(1ll*j*j*t0+s3[j+1])%P;
Az(f[y].a[j],t1); s3[j+1]=(1ll*j*t1+s3[j+1])%P; Az(f[y].b[j],t2); Az(s3[j+1],t2);
}
for(int j=n;j;--j) Az(s0[j],s0[j+1]), Az(s1[j],s1[j+1]);
for(int j=1;j<=n;++j)
{
Az(s2[j],s2[j-1]); Az(s3[j],s3[j-1]);
f[y].a[j]=(1ll*s0[j]+f[y].a[j])*w[j]%P;
f[y].b[j]=(s1[j]*(j-1ll)+f[y].b[j])%P*w[j]%P;
f[y].c[j]=(s2[j]*(j-1ll)*(j-1)+s3[j])%P*w[j]%P;
}
}
for(int i=1;i<=n;++i) an=(1ll*f[x].a[i]*i*i+1ll*f[x].b[i]*i+f[x].c[i]+an)%P;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3932kb
input:
3 1 2 3 4 1 1 1 1
output:
72 256
result:
ok 2 number(s): "72 256"
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3884kb
input:
20 2 1 1 2 1 1 2 2 1 1 1 2 1 2 2 2 2 2 1 1 20 1 1 1 1 1 1 1 2 2 2 2 1 2 1 2 1 1 1 2 2 20 2 1 2 2 1 2 2 1 1 1 2 1 2 1 2 2 1 1 2 1 20 1 1 1 1 1 2 1 1 1 2 1 2 2 1 1 2 2 2 1 2 20 2 2 1 1 2 2 2 1 2 2 1 2 2 2 2 1 2 2 2 2 20 1 1 2 1 2 1 2 2 1 2 2 2 1 2 1 2 2 2 1 1 20 1 2 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 2 2 1...
output:
670201383 978149714 255510037 243289849 477813105 946659908 735344119 572611881 960574967 630065160 752230920 277199417 712727757 255187153 379136387 703031040 405965430 289052839 473467311 265002502 623623558 452186341 971590933 444524761 448417614 233916064 41960694 450102968 936903310 104224765 6...
result:
wrong answer 1st numbers differ - expected: '319733964', found: '670201383'