QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#113059 | #6346. Record Parity | Komorebi_03 | WA | 4ms | 21128kb | C++14 | 1.3kb | 2023-06-16 08:53:31 | 2023-06-16 08:53:33 |
Judging History
answer
//By:Komorebi_03
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int N = 1e6+10;
int n,k,cnt,Min=INF,p[N],inv[N],fac[N];
inline int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
int out(int x)
{
if(x<0)
return x+MOD;
return x;
}
int ksm(int a,int b)
{
int k=1;
while (b)
{
if(b%2==0)
k=k*a%MOD;
a=a*a%MOD;
b/=2;
}
return k;
}
int C(int x,int y)
{
if(x<y)
return 0;
return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void init()
{
fac[0]=1;
for (int i=1;i<=N;i++)
fac[i]=fac[i-1]*i%MOD;
inv[N]=ksm(fac[N],MOD-2);
for (int i=N-1;i>=0;i--)
inv[i]=inv[i+1]*(i+1)%MOD;
}
signed main()
{
n=read();
k=read();
init();
for (int i=1;i<=n;i++)
p[i]=read();
for (int i=n;i>=1;i--)
{
Min=min(Min,p[i]);
if(p[i]==Min)
cnt++;
}
if(k&1)
cout<<out(-C(cnt,k));
else
cout<<C(cnt,k);
return 0;
//Amireux_35
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 21128kb
input:
5 2 4 1 2 5 3
output:
508369142
result:
wrong answer 1st numbers differ - expected: '3', found: '508369142'