結果

問題 No.1885 Flat Permutation
ユーザー SSRSSSRS
提出日時 2022-03-25 21:55:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 195,956 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 06:37:02
合計ジャッジ時間 3,463 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
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 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 4 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 4 ms
5,376 KB
testcase_33 AC 4 ms
5,376 KB
testcase_34 AC 5 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 4 ms
5,376 KB
testcase_39 AC 4 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>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  if (X > Y){
    swap(X, Y);
  }
  vector<long long> dp(N, 0);
  if (X == 0){
    dp[0] = 1;
  } else {
    dp[X + 1] = 1;
  }
  for (int i = 0; i < N - 1; i++){
    dp[i + 1] += dp[i];
    dp[i + 1] %= MOD;
    if (i < N - 3){
      dp[i + 3] += dp[i];
      dp[i + 3] %= MOD;
    }
  }
  long long ans = 0;
  for (int i = 0; i < Y; i++){
    if ((Y - i) % 2 == 1){
      ans += dp[i];
    }
  }
  if (X == N - 2 && Y == N - 1){
    ans++;
  }
  ans %= MOD;
  cout << ans << endl;
}
0