結果
問題 | No.2575 Almost Increasing Sequence |
ユーザー | noshi91 |
提出日時 | 2023-10-31 01:49:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,656 bytes |
コンパイル時間 | 2,591 ms |
コンパイル使用メモリ | 227,096 KB |
実行使用メモリ | 6,548 KB |
スコア | 0 |
最終ジャッジ日時 | 2023-12-02 23:33:59 |
合計ジャッジ時間 | 3,814 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
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 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using mint = atcoder::modint998244353; static constexpr int N = 10; using poly = std::array<mint, N + 1>; using coef = std::array<int, 4>; using hp = std::map<coef, poly>; coef add(coef c, int i) { c[i]++; return c; } coef proj(coef c, int i) { c[i] = 0; return c; } int main() { int K; std::cin >> K; std::array<mint, N + 1> fact, ifact; fact[0] = 1; for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i; ifact[N] = 1 / fact[N]; for (int i = N; i >= 1; i--) ifact[i - 1] = ifact[i] * i; std::map<coef, mint> pd; pd[{0, 0, 0, 0}] = 1; for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { // x_i - x_j + (j-i) for (int k = 0; k < 2; k++) { std::map<coef, mint> nx; for (const auto &[c, v] : pd) { nx[add(c, i)] += v; nx[add(c, j)] -= v; nx[c] += v * (j - i); } pd = std::move(nx); } } } for (auto it = pd.begin(); it != pd.end();) { if (it->second == mint(0)) it = pd.erase(it); else ++it; } poly ans; std::array<hp, 4> dp; for (int col = 0; col + 4 <= N; col++) { for (int i = 1; i < 4; i++) { int st = std::min(col * i, N + 1); int w = std::min(i, N + 1 - st); for (auto &[c, v] : dp[i]) { std::copy_backward(v.begin() + st, v.end() - w, v.end()); std::fill(v.begin() + st, v.begin() + st + w, mint(0)); } } std::array<mint, 7> pow; pow[0] = 1; for (int i = 1; i < 7; i++) pow[i] = pow[i - 1] * (col + 1); { int h = (col + 1) * 4; if (h < N + 1) { mint a = ifact[col + 1] * ifact[col + 1]; std::array<mint, 7> pc; for (int j = 0; j < 7; j++) pc[j] = a * pow[j]; for (const auto &[c, v] : pd) { dp[3][proj(c, 3)][h] += pc[c[3]] * v; } } } poly temp; for (int i = 2; i >= 0; i--) { int h = (col + 1) * (i + 1); if (h >= N + 1) continue; mint a = ifact[col + 4 - i] * ifact[col + 4 - i]; std::array<mint, 7> pc; for (int j = 0; j < 7; j++) pc[j] = a * pow[j]; for (const auto &[c, v] : dp[i + 1]) { auto &t = i ? dp[i][proj(c, i)] : temp; mint aa = pc[c[i]]; for (int k = h; k < N + 1; k++) t[k] += aa * v[k]; } } mint a = mint(col + 1).pow(K); for (int k = 0; k < N + 1; k++) { ans[k] += a * temp[k]; } } std::cout << N << "\n"; for (int i = 1; i <= N; i++) { std::cout << (ans[i] * fact[i] * fact[i]).val() << " \n"[i == N]; } return 0; }