結果

問題 No.1885 Flat Permutation
ユーザー NoviNovi
提出日時 2022-03-26 13:26:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,633 bytes
コンパイル時間 4,105 ms
コンパイル使用メモリ 227,056 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 05:34:51
合計ジャッジ時間 5,593 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 3 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define int ll
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define ALL(a) (a).begin(), (a).end()
template <class t, class u> void chmax(t& a, u b) {
    if (a < b) a = b;
}
template <class t, class u> void chmin(t& a, u b) {
    if (b < a) a = b;
}
template <class t> using vc = vector<t>;
template <class t> using vvc = vc<vc<t>>;
using pi = pair<int, int>;
using vi = vc<int>;
using uint = unsigned;
using ull = unsigned long long;
int popcount(signed t) { return __builtin_popcount(t); }
int popcount(ll t) { return __builtin_popcountll(t); }
bool ispow2(int i) { return i && (i & -i) == i; }
ll mask(int i) { return (ll(1) << i) - 1; }
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
    using mint = atcoder::modint998244353;
    int n, x, y;
    cin >> n >> x >> y;
    if (x > y) swap(x, y);
    x--, y--;
    vc<mint> dp(n);
    if (x == 0) {
        // 上がるだけ
        dp[x] = 1;
    } else {
        // X~0~X-1->(+2)->Yしかない
        // x+1からは通常通り数える
        dp[x + 1] = 1;
    }
    rep(i, n - 1) {
        dp[i + 1] += dp[i];
        if (i < n - 3) {
            dp[i + 1] += dp[i];
        }
    }
    mint ans = dp[y - 1];
    if (y == n - 1) {
        // ラスト1回
        if (y >= 3) {
            ans += dp[y - 3];
        }
        // 端数が2のとき
        if (n != 2 && x == n - 2) ans++;
    }
    cout << ans.val() << endl;
}
0