QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#240790 | #6346. Record Parity | ylf# | WA | 1ms | 8048kb | C++14 | 892b | 2023-11-05 19:00:35 | 2023-11-05 19:00:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
char ch;
while((ch=getchar())<'0'||ch>'9');
int res=ch-'0';
while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0';
return res;
}
const int N=1000100;
const int mod=998244353;
int n,a[N],jc[N],ny[N];
int ksm(int x,int K)
{
int res=1;
while(K)
{
if(K&1) res=1ll*res*x%mod;
K>>=1;
x=1ll*x*x%mod;
}
return res;
}
int C(int n,int m)
{
return 1ll*jc[n]*ny[n-m]%mod*ny[m]%mod;
}
int main()
{
n=read();int K=read();
jc[0]=1;
for(int i=1;i<=n;i++) a[i]=read(),jc[i]=1ll*jc[i-1]*i%mod;
ny[n]=ksm(jc[n],mod-2);
for(int i=n-1;i>=0;i--) ny[i]=1ll*ny[i+1]*(i+1)%mod;
int lst=0,ans=0;
for(int i=1;i<=n;i++)
{
if(i==1||a[i]>a[i-1]) lst++;
else lst=1;
if(lst>=K) (ans+=C(lst-1,K-1))%=mod;
}
if(K&1) printf("%d",(mod-ans)%mod);
else printf("%d",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7836kb
input:
5 2 4 1 2 5 3
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 1ms
memory: 8048kb
input:
7 3 1 2 3 4 5 6 7
output:
998244318
result:
ok 1 number(s): "998244318"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7896kb
input:
5 5 2 5 4 1 3
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 7976kb
input:
10 3 9 7 3 6 10 4 8 2 5 1
output:
998244352
result:
wrong answer 1st numbers differ - expected: '0', found: '998244352'