QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524146#5039. Black and WhiteCelebrateWA 3ms5188kbC++141.4kb2024-08-19 11:08:252024-08-19 11:08:26

Judging History

This is the latest submission verdict.

  • [2024-08-19 11:08:26]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 5188kb
  • [2024-08-19 11:08:25]
  • Submitted

answer

#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define dwn(i,x,y) for(int i=x;i>=y;i--)
#define ll long long
using namespace std;
template<typename T>inline void qr(T &x){
    x=0;int f=0;char s=getchar();
    while(!isdigit(s))f|=s=='-',s=getchar();
    while(isdigit(s))x=x*10+s-48,s=getchar();
    x=f?-x:x;
}
int cc=0,buf[31];
template<typename T>inline void qw(T x){
    if(x<0)putchar('-'),x=-x;
    do{buf[++cc]=int(x%10);x/=10;}while(x);
    while(cc)putchar(buf[cc--]+'0');
}
const int N=2e5+10,mod=998244353;
int fc[N],ifc[N];
int power(int a,int b){
    int ret=1;
    while(b){
        if(b&1)ret=1ll*ret*a%mod;
        a=1ll*a*a%mod;b>>=1;
    }
    return ret;
}
int C(int a,int b){
    if(a<0||b<0||a<b)return 0;
    return 1ll*fc[a]*ifc[b]%mod*ifc[a-b]%mod;
}
int work(int n,int m,int k){
    k+=n/2;
    return 1ll*C((n+m)/2,k)*C((n+m)/2,n-k)%mod;
}
void solve(){
    int n,m,k;qr(n),qr(m),qr(k);
    if((n+m)%2==0)qw(work(n,m,k)),puts("");
    else{
        int ans=work(n,m-1,k);
        if(m&1)ans=(ans+work(n-1,m,k+1));
        else ans=(ans+work(n-1,m,k-1));
        qw(ans);puts("");
    }
}
int main(){
    fc[0]=1;rep(i,1,200000)fc[i]=1ll*fc[i-1]*i%mod;
    ifc[200000]=power(fc[200000],mod-2);
    dwn(i,199999,0)ifc[i]=1ll*ifc[i+1]*(i+1)%mod;
    int tt;qr(tt);
    while(tt--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5168kb

input:

5
1 1 0
1 1 -1
2 2 1
2 2 0
4 4 1

output:

1
0
1
4
16

result:

ok 5 number(s): "1 0 1 4 16"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 5188kb

input:

100
1 1 -10
1 1 -9
1 1 -8
1 1 -7
1 1 -6
1 1 -5
1 1 -4
1 1 -3
1 1 -2
1 1 -1
1 1 0
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 1 7
1 1 8
1 1 9
1 1 10
1 2 -10
1 2 -9
1 2 -8
1 2 -7
1 2 -6
1 2 -5
1 2 -4
1 2 -3
1 2 -2
1 2 -1
1 2 0
1 2 1
1 2 2
1 2 3
1 2 4
1 2 5
1 2 6
1 2 7
1 2 8
1 2 9
1 2 10
1 3 -10
1 3 -9
1 3 -...

output:

0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
3
0
0
0
0

result:

wrong answer 32nd numbers differ - expected: '2', found: '1'