QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#113059#6346. Record ParityKomorebi_03WA 4ms21128kbC++141.3kb2023-06-16 08:53:312023-06-16 08:53:33

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:53:33]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:21128kb
  • [2023-06-16 08:53:31]
  • 提交

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'