結果

問題 No.1885 Flat Permutation
ユーザー bonKotsubonKotsu
提出日時 2022-08-04 00:03:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 4,464 ms
コンパイル使用メモリ 263,484 KB
実行使用メモリ 14,320 KB
最終ジャッジ日時 2023-10-11 19:39:54
合計ジャッジ時間 6,933 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 4 ms
4,652 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 17 ms
14,172 KB
testcase_17 AC 17 ms
14,100 KB
testcase_18 AC 18 ms
14,040 KB
testcase_19 AC 18 ms
14,148 KB
testcase_20 AC 18 ms
14,100 KB
testcase_21 AC 18 ms
14,052 KB
testcase_22 AC 17 ms
14,112 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 18 ms
14,080 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 AC 18 ms
13,972 KB
testcase_27 AC 18 ms
14,320 KB
testcase_28 AC 18 ms
14,036 KB
testcase_29 AC 17 ms
14,020 KB
testcase_30 AC 17 ms
13,968 KB
testcase_31 AC 18 ms
14,036 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 17 ms
14,020 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 17 ms
14,168 KB
testcase_36 AC 18 ms
14,092 KB
testcase_37 AC 17 ms
14,044 KB
testcase_38 AC 2 ms
4,352 KB
testcase_39 AC 2 ms
4,352 KB
testcase_40 AC 12 ms
9,824 KB
testcase_41 AC 15 ms
11,932 KB
testcase_42 AC 8 ms
7,044 KB
testcase_43 AC 18 ms
14,164 KB
testcase_44 AC 18 ms
14,124 KB
testcase_45 AC 18 ms
14,120 KB
testcase_46 AC 18 ms
14,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define LP pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
template<class T>
void chmax(T& a, T b) { a = max(a, b); };
template<class T>
void chmin(T& a, T b) { a = min(a, b); };
using mint = modint998244353;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  if (x > y) swap(x,y);
  if (x == 1 && y == 2) {
    cout << 1 << endl;
    return 0;
  }

  if (n==2&&x==1&&y==2) {
    cout << 1 << endl;
    return 0;
  }
  if (x ==n-1 && y == n) {
    cout << 1 << endl;
    return 0;
  }
  if (y-1==x) {
    cout << 0 << endl;
    return 0;
  }
  int d = y-1-(x+1)+1;
  if (x == 1) d++;
  if (y == n) d++;
  vector dp(n+1, vector<mint>(2));
  dp[1][0] = 1;
  for (int i = 1; i < n; i++) {
    dp[i+1][0] = dp[i][0]+dp[i][1];
    dp[i+1][1] = dp[i-1][0];
  }
  cout << dp[d][0].val() << endl;
  
  return 0;
}
0