ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214538 | #2486. 小根堆 | a_sad_soul | 20 | 41ms | 25580kb | C++11 | 1.1kb | 2024-11-19 21:42:00 | 2024-11-19 23:03:12 |
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int MAXN = 1e6+10;
ll fac[MAXN],rev[MAXN];
ll siz[MAXN<<1];bool is[MAXN];
#define ls(p)(p<<1)
#define rs(p)(p<<1|1)
ll ksm(ll a,ll b){
ll re=1;
while(b){
if(b&1)re=re*a%mod;
a=a*a%mod;
b>>=1;
}
return re;
}
int n;
void Init(){
fac[0]=1;
for(int i=1;i<=n;++i)fac[i]=fac[i-1]*i%mod;
rev[n]=ksm(fac[n],mod-2);
for(int i=n-1;~i;--i)rev[i]=rev[i+1]*(i+1)%mod;
}
ll C(int n,int m){
// if(n<m||n<=0||m<0)return 0;
if(n<m)return 0;
return fac[n]*rev[m]%mod*rev[n-m]%mod;
}
void dfs(int u){
if(u>n)return ;
dfs(ls(u)),dfs(rs(u));
siz[u]=1+siz[ls(u)]+siz[rs(u)];
is[u]|=is[ls(u)]|is[rs(u)];
}
ll calc(int u){
if(u>n)return 1;
return C(siz[u]-1,siz[ls(u)])*calc(ls(u))%mod*calc(rs(u))%mod;
}
int x,y;
int main(){
cin>>n>>x>>y;
is[x]=1;
Init();dfs(1);
if(n-y+1>siz[x]){
puts("0");return 0;
}
cout<<calc(1)<<endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1176kb
input:
5 2 2
output:
0
result:
wrong answer 1st lines differ - expected: '6', found: '0'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 1172kb
input:
10 4 3
output:
0
result:
wrong answer 1st lines differ - expected: '840', found: '0'
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 1172kb
input:
20 18 19
output:
0
result:
wrong answer 1st lines differ - expected: '134772704', found: '0'
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 1176kb
input:
30 20 16
output:
0
result:
wrong answer 1st lines differ - expected: '862828891', found: '0'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
50 1 1
output:
454716180
result:
ok single line: '454716180'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1228kb
input:
1000 1 1
output:
517631465
result:
ok single line: '517631465'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 1196kb
input:
1000 765 669
output:
0
result:
wrong answer 1st lines differ - expected: '582857574', found: '0'
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 1200kb
input:
1000 149 293
output:
0
result:
wrong answer 1st lines differ - expected: '25668476', found: '0'
Test #9:
score: 0
Wrong Answer
time: 5ms
memory: 3616kb
input:
100000 42608 7968
output:
0
result:
wrong answer 1st lines differ - expected: '754109918', found: '0'
Test #10:
score: 0
Wrong Answer
time: 35ms
memory: 25580kb
input:
1000000 921152 658527
output:
0
result:
wrong answer 1st lines differ - expected: '563335284', found: '0'