結果
問題 | No.1885 Flat Permutation |
ユーザー |
|
提出日時 | 2022-03-25 21:36:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 3,089 ms |
コンパイル使用メモリ | 247,356 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 05:30:34 |
合計ジャッジ時間 | 4,589 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using Mint = atcoder::modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, X, Y; cin >> N >> X >> Y; if(X>Y) swap(X, Y); if(X != 1) ++X; if(Y != N) --Y; int D = Y - X; if(D < 0) { cout << 0 << endl; } else { vector<Mint> DP(max(3, D+1)); DP[0] = 1; DP[1] = 1; DP[2] = 1; for(int i=3; i<=D; ++i) DP[i] = DP[i-1]+DP[i-3]; cout << DP[D].val() << endl; } }