結果
| 問題 |
No.1885 Flat Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-13 12:49:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 906 bytes |
| コンパイル時間 | 869 ms |
| コンパイル使用メモリ | 106,940 KB |
| 最終ジャッジ日時 | 2025-02-15 10:09:39 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include <unordered_set>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
ll solve(int D){
//0,1,2,3..,D
vector<ll> dp(D+2,0);
dp[0]=1;
for(int i=1;i<=D;i++){
if(i>=1){
dp[i]+=dp[i-1];
dp[i]%=MOD;
}
if(i>=3){
dp[i]+=dp[i-3];
dp[i]%=MOD;
}
}
return dp[D];
}
int main(){
int N,X,Y;
cin>>N>>X>>Y;
if(X>Y) swap(X,Y);
//X<Y
int X0=(X==1?1:X+1);
int Y0=(Y==N?N:Y-1);
int D=Y0-X0;
//cout<<"D="<<D<<endl;
if(D<0){
cout<<0<<endl;
return 0;
}else{
cout<<solve(D)<<endl;
}
}