QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#113052#6346. Record ParityKomorebi_03WA 8ms12636kbC++141.2kb2023-06-16 08:29:442023-06-16 08:29:46

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-16 08:29:46]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:12636kb
  • [2023-06-16 08:29:44]
  • 提交

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
}

Details

Tip: Click on the bar to expand more detailed information

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'