結果
問題 | No.2303 Frog on Grid |
ユーザー | FUN_Morikubo |
提出日時 | 2023-06-14 23:31:51 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 3,857 bytes |
コンパイル時間 | 4,263 ms |
コンパイル使用メモリ | 239,312 KB |
実行使用メモリ | 15,996 KB |
最終ジャッジ日時 | 2024-06-23 04:39:30 |
合計ジャッジ時間 | 5,646 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 49 ms
13,916 KB |
testcase_03 | AC | 25 ms
8,332 KB |
testcase_04 | AC | 49 ms
13,620 KB |
testcase_05 | AC | 50 ms
14,772 KB |
testcase_06 | AC | 25 ms
8,660 KB |
testcase_07 | AC | 47 ms
13,248 KB |
testcase_08 | AC | 48 ms
13,432 KB |
testcase_09 | AC | 13 ms
5,764 KB |
testcase_10 | AC | 22 ms
7,892 KB |
testcase_11 | AC | 13 ms
5,872 KB |
testcase_12 | AC | 27 ms
9,708 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 54 ms
15,868 KB |
testcase_19 | AC | 53 ms
15,872 KB |
testcase_20 | AC | 52 ms
15,996 KB |
testcase_21 | AC | 53 ms
15,876 KB |
testcase_22 | AC | 52 ms
15,872 KB |
ソースコード
#if 1 // clang-format off #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; typedef modint998244353 mint93; typedef modint1000000007 mint17; typedef modint mint; using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using lf = long double; using pll = pair<ll, ll>; #define vec vector template <class T> using v = vector<T>; template <class T> using vv = v<v<T>>; template <class T> using vvv = v<vv<T>>; using vl = v<ll>; using vvl = vv<ll>; using vvvl = vvv<ll>; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, N) for (ll i = 0; i < (ll)(N); i++) #define rep1(i, N) for (ll i = 1; i <= (ll)(N); i++) #define rrep(i, N) for (ll i = N - 1; i >= 0; i--) #define rrep1(i, N) for (ll i = N; i > 0; i--) #define fore(i, a) for (auto &i : a) #define fs first #define sc second #define eb emplace_back #define pb push_back #define all(x) (x).begin(), (x).end() #define UNIQUE(x) (x).erase(unique((x).begin(), (x).end()), (x).end()); #define YES(x) cout << ((x) ? "YES\n" : "NO\n"); #define Yes(x) cout << ((x) ? "Yes\n" : "No\n"); #define yes(x) cout << ((x) ? "yes\n" : "no\n"); #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) template <class T, class U> void chmin(T &t, const U &u) { if (t > u) t = u; } template <class T, class U> void chmax(T &t, const U &u) { if (t < u) t = u; } const int inf = (1 << 29); const ll infl = (1LL << 60); const ll mod93 = 998244353; const ll mod17 = 1000000007; int popcnt(uint x) { return __builtin_popcount(x); } int popcnt(ull x) { return __builtin_popcountll(x); } int bsr(uint x) { return 31 - __builtin_clz(x); } int bsr(ull x) { return 63 - __builtin_clzll(x); } int bsf(uint x) { return __builtin_ctz(x); } int bsf(ull x) { return __builtin_ctzll(x); } template <class T> istream &operator>>(istream &is, vector<T> &x) { for (auto &y : x) is >> y; return is; } template <class T> ostream &operator<<(ostream &os, vector<T> &x) { for (unsigned int i = 0, size = x.size(); i < size; i++) os << x[i] << (i == size - 1 ? "" : " "); return os; } template <class T, class S> istream &operator>>(istream &is, pair<T, S> &x) { return is >> x.first >> x.second; } template <class T, class S> ostream &operator<<(ostream &os, pair<T, S> &x) { return os << x.first << " " << x.second; } ll rand_int(ll l, ll r) { // [l, r] static random_device rd; static mt19937 gen(rd()); return uniform_int_distribution<ll>(l, r)(gen); } template <long long MOD = 998244353> struct binomial { long long n; std::vector<atcoder::static_modint<MOD>> fact, ifact; binomial(long long n) : n(n), fact(n + 1), ifact(n + 1) { fact[0] = 1; for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i > 0; i--) ifact[i - 1] = ifact[i] * i; } atcoder::static_modint<MOD> operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; // clang-format on #endif // #define _GLIBCXX_DEBUG void solve() { ll h, w; cin >> h >> w; v<mint93> a(h + 1), b(w + 1); // c1 + c2 = i // c1 + 2 * c2 = h binomial<mod93> comb(2 * (h + w)); rep(i, h + 1) { ll c2 = h - i; ll c1 = h - 2 * c2; a[i] = comb(i, c1) * comb.ifact[i]; } rep(i, w + 1) { ll c2 = w - i; ll c1 = w - 2 * c2; b[i] = comb(i, c1) * comb.ifact[i]; } v<mint93> c = convolution(a, b); // cout << h << " " << w << " " << c.size() << endl; mint93 ans = 0; rep(i, c.size()) { ans += c[i] * comb.fact[i]; } cout << ans.val() << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); ll t = 1; // cin >> t; while (t--) solve(); }