結果

問題 No.2237 Xor Sum Hoge
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-10-05 13:01:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,096 bytes
コンパイル時間 4,602 ms
コンパイル使用メモリ 268,400 KB
実行使用メモリ 6,048 KB
最終ジャッジ日時 2023-10-05 13:01:51
合計ジャッジ時間 15,977 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 518 ms
5,928 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 112 ms
4,376 KB
testcase_12 AC 241 ms
4,428 KB
testcase_13 AC 513 ms
5,700 KB
testcase_14 WA -
testcase_15 AC 117 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 503 ms
5,180 KB
testcase_18 WA -
testcase_19 AC 232 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 7 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

struct Fast {
  Fast() {
    std::cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
  }
} fast;

#define all(a) (a).begin(), (a).end()
#define contains(a, x) ((a).find(x) != (a).end())
#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--)
#define writejoin(s, a) rep(_i, 0, (a).size()) cout << (a)[_i] << (_i + 1 < (int)(a).size() ? s : "\n");
#define YN(b) cout << ((b) ? "YES" : "NO") << "\n";
#define Yn(b) cout << ((b) ? "Yes" : "No") << "\n";
#define yn(b) cout << ((b) ? "yes" : "no") << "\n";

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using mint = modint998244353;
using vm = vector<mint>;

template <typename mint>
class Factorial {
 public:
  Factorial(int max) : n(max) {
    f = vector<mint>(n + 1);
    finv = vector<mint>(n + 1);
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i;
    finv[n] = f[n].inv();
    for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * i;
  }
  mint fact(int k) {
    assert(0 <= k && k <= n);
    return f[k];
  }
  mint fact_inv(int k) {
    assert(0 <= k && k <= n);
    return finv[k];
  }
  mint binom(int k, int r) {
    assert(0 <= k && k <= n);
    if (r < 0 || r > k) return 0;
    return f[k] * finv[r] * finv[k - r];
  }
  mint inv(int k) {
    assert(0 < k && k <= n);
    return finv[k] * f[k - 1];
  }

 private:
  int n;
  vector<mint> f, finv;
};

int main() {
  const int LOG = 60;
  int n;
  ll b, c;
  cin >> n >> b >> c;
  Factorial<mint> fact(n);

  vm dp(n + 1, 0);
  dp[0] = 1;
  rrep(k, 0, LOG) {
    int bd = (int)((b >> k) & 1);
    int cd = (int)((c >> k) & 1);
    vm f(n + 1, 0), g(n + 1, 0);
    for (int i = bd; i <= n; i += 2) f[i] = dp[i / 2];
    for (int j = cd; j <= n; j += 2) g[n - j] = fact.binom(n, j);
    auto h = convolution(f, g);
    dp = vm(n + 1, 0);
    for (int i = bd ^ cd; i <= n; i += 2) dp[i] = h[n + i];
  }
  cout << dp[0].val() << endl;
}
0