ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214521 | #2486. 小根堆 | White_Wat | 0 | 107ms | 1364kb | C++11 | 1.1kb | 2024-11-19 20:14:26 | 2024-11-19 23:01:26 |
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5, mod = 998244353;
typedef long long ll;
int n,x,y;
ll f[1004][1004];
ll ans;
ll sum[1004][1004];
void dfs(int u){
for(int i=1;i<=n;i++){
f[u][i]=1;
if(2*u>n){
continue;
}
dfs(2*u);
int ls=0,rs=0;
// for(int j=i+1;j<=n;j++)
// ls+=f[2*u][j];
ls=(sum[2*u][n]-sum[2*u][i]+mod)%mod;
if(2*u+1>n){
f[u][i]=ls;
continue;
}
dfs(2*u+1);
// for(int j=i+1;j<=n;j++)
// rs+=f[2*u+1][j];
rs=(sum[2*u+1][n]-sum[2*u+1][i]+mod)%mod;
// cout<<ls<<':'<<rs<<'\n';
f[u][i]=ls*rs%mod;
}
for(int i=1;i<=n;i++){
sum[u][i]=(sum[u][i-1]+f[u][i])%mod;
}
}
int main(){
// ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
cin>>x>>y;
dfs(1);
ans=0;
for(int i=1;i<=n;i++)
(ans+=f[1][i])%=mod;
// for(int i=1;i<=n;i++){
// for(int j=1;j<=n;j++)
// cout<<f[i][j]<<' ';
// cout<<'\n';
// }
cout<<ans%mod<<'\n';
return 0;
}
/*
考虑树形 dp
树高不超过 log2(n)
完全二叉树 n 个节点
x 到根 1 的节点值域为 val[1]+1~val[x]-1
*/
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1244kb
input:
5 2 2
output:
73
result:
wrong answer 1st lines differ - expected: '6', found: '73'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 1284kb
input:
10 4 3
output:
2015168
result:
wrong answer 1st lines differ - expected: '840', found: '2015168'
Test #3:
score: 0
Wrong Answer
time: 107ms
memory: 1364kb
input:
20 18 19
output:
992228808
result:
wrong answer 1st lines differ - expected: '134772704', found: '992228808'
Test #4:
score: 0
Time Limit Exceeded
input:
30 20 16
output:
result:
Test #5:
score: 0
Time Limit Exceeded
input:
50 1 1
output:
result:
Test #6:
score: 0
Time Limit Exceeded
input:
1000 1 1
output:
result:
Test #7:
score: 0
Time Limit Exceeded
input:
1000 765 669
output:
result:
Test #8:
score: 0
Time Limit Exceeded
input:
1000 149 293
output:
result:
Test #9:
score: 0
Runtime Error
input:
100000 42608 7968
output:
result:
Test #10:
score: 0
Runtime Error
input:
1000000 921152 658527