結果

問題 No.2303 Frog on Grid
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-05-12 22:09:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,144 bytes
コンパイル時間 3,885 ms
コンパイル使用メモリ 268,636 KB
実行使用メモリ 9,584 KB
最終ジャッジ日時 2023-08-19 04:57:58
合計ジャッジ時間 5,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,152 KB
testcase_01 AC 7 ms
6,220 KB
testcase_02 AC 22 ms
9,308 KB
testcase_03 AC 15 ms
7,504 KB
testcase_04 AC 22 ms
9,016 KB
testcase_05 AC 27 ms
9,160 KB
testcase_06 AC 14 ms
7,424 KB
testcase_07 AC 23 ms
8,956 KB
testcase_08 AC 23 ms
8,860 KB
testcase_09 AC 10 ms
6,988 KB
testcase_10 AC 13 ms
7,368 KB
testcase_11 AC 10 ms
7,076 KB
testcase_12 AC 14 ms
7,552 KB
testcase_13 AC 6 ms
6,220 KB
testcase_14 AC 6 ms
6,292 KB
testcase_15 AC 6 ms
6,192 KB
testcase_16 AC 6 ms
6,192 KB
testcase_17 AC 6 ms
6,300 KB
testcase_18 AC 23 ms
9,384 KB
testcase_19 AC 23 ms
9,376 KB
testcase_20 AC 23 ms
9,480 KB
testcase_21 AC 22 ms
9,300 KB
testcase_22 AC 23 ms
9,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using namespace atcoder;

struct Fast
{
  Fast()
  {
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;

#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 ll long long

template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

using mint = modint998244353;

int main()
{
  int h, w;
  cin >> h >> w;

  int n = 4e5;
  vector<mint> fact(n + 1), ifact(n + 1);
  fact[0] = 1;
  rep(i, 0, n) fact[i + 1] = fact[i] * (i + 1);
  ifact[n] = fact[n].inv();
  rrep(i, 0, n) ifact[i] = ifact[i + 1] * (i + 1);

  vector<mint> f(h / 2 + 1, 0), g(w / 2 + 1, 0);
  rep(i, 0, h / 2 + 1) f[i] = ifact[i] * ifact[h - 2 * i];
  rep(i, 0, w / 2 + 1) g[i] = ifact[i] * ifact[w - 2 * i];

  auto a = convolution(f, g);
  mint ans = 0;
  rep(i, 0, a.size()) ans += a[i] * fact[h + w - i];
  cout << ans.val() << endl;
}
0