ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214547 | #2486. 小根堆 | naroto2022 | 20 | 0ms | 1132kb | C++ | 931b | 2024-11-19 22:32:36 | 2024-11-19 23:04:24 |
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
const int mod=998244353;
const int MN=1e6+5;
ll ans,n,x,y,a[MN];
bool vis[MN];
void write(ll n){if(n<0){putchar('-');write(-n);return;}if(n>9)write(n/10);putchar(n%10+'0');}
ll read(){ll 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<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
void dfs(ll step){
if(step==x){
if(a[step/2]<a[step]) dfs(step+1);
return;
}
if(step==n+1){
ans=(ans+1)%mod;
return;
}
for(int i=a[step/2]+1; i<=n; i++) if(!vis[i]){
a[step]=i;vis[i]=true;
dfs(step+1);
vis[i]=false;
}
}
int main(){
n=read();x=read();y=read();
a[x]=y;vis[y]=true;
dfs(1);
write(ans);putchar('\n');
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1132kb
input:
5 2 2
output:
6
result:
ok single line: '6'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1128kb
input:
10 4 3
output:
840
result:
ok single line: '840'
Test #3:
score: 0
Time Limit Exceeded
input:
20 18 19
output:
result:
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
Time Limit Exceeded
input:
100000 42608 7968
output:
result:
Test #10:
score: 0
Time Limit Exceeded
input:
1000000 921152 658527