QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#113052 | #6346. Record Parity | Komorebi_03 | WA | 8ms | 12636kb | C++14 | 1.2kb | 2023-06-16 08:29:44 | 2023-06-16 08:29:46 |
Judging History
answer
//By:Komorebi_03
#include<bits/stdc++.h>
using namespace std;
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;
}
int 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
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 12636kb
input:
5 2 4 1 2 5 3
output:
-30101778
result:
wrong answer 1st numbers differ - expected: '3', found: '-30101778'