結果
問題 | No.1885 Flat Permutation |
ユーザー |
![]() |
提出日時 | 2023-08-12 00:46:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 5,472 ms |
コンパイル使用メモリ | 308,532 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 20:24:20 |
合計ジャッジ時間 | 6,558 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair<int,int>; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n,x,y;cin>>n>>x>>y; if(x>y)swap(x,y); int d=y-x-1; if(y==n)d++; if(x==1)d++; vc<mint>dp(d+1,0); dp[1]=1; for(int i=2;i<=d;i++){ dp[i]+=dp[i-1]; if(i-3>=1)dp[i]+=dp[i-3]; } cout<<dp[d].val(); }