結果
問題 |
No.1885 Flat Permutation
|
ユーザー |
|
提出日時 | 2022-03-25 23:21:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 752 bytes |
コンパイル時間 | 1,746 ms |
コンパイル使用メモリ | 169,900 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-14 07:31:17 |
合計ジャッジ時間 | 2,895 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template <class T> using V = vector<T>; #include <atcoder/modint> using namespace atcoder; using mint = 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); int lb = (X == 1 ? X : X + 1); int ub = (Y == N ? Y : Y - 1); int len = ub - lb + 1; V<mint> p(N + 1, 0); p[0] = 0, p[1] = 1, p[2] = 1; for (int i = 3; i <= N; i++) p[i] = p[i - 1] + p[i - 3]; len = max(len, 0); mint ans = p[len]; cout << ans.val() << '\n'; return 0; }