結果

問題 No.1513 simple 門松列 problem
ユーザー KudeKude
提出日時 2021-05-21 22:31:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,753 bytes
コンパイル時間 4,381 ms
コンパイル使用メモリ 256,012 KB
実行使用メモリ 214,720 KB
最終ジャッジ日時 2024-04-18 16:04:22
合計ジャッジ時間 6,432 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
214,464 KB
testcase_01 AC 53 ms
214,460 KB
testcase_02 AC 84 ms
214,456 KB
testcase_03 AC 53 ms
214,460 KB
testcase_04 AC 53 ms
214,460 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 54 ms
214,588 KB
testcase_09 AC 52 ms
214,460 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 53 ms
214,336 KB
testcase_13 AC 53 ms
214,456 KB
testcase_14 WA -
testcase_15 AC 84 ms
214,588 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 54 ms
214,464 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n)for (int i = 0; i < int(n); ++i)
#define rrep(i,n)for (int i = int(n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint998244353;

mint dp1[300][300][300], dp2[300][300][300];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    rep(b, k) rep(a, b) {
        dp1[0][a][b] = 1;
        dp2[0][a][b] = a + b;
    }
    rep(i, n - 2) {
        if (i % 2 == 0) {
            rep(b, k) {
                mint v1 = 0, v2 = 0;
                rep(a, b) v1 += dp1[i][a][b], v2 += dp2[i][a][b];
                rep(c, b) {
                    dp1[i+1][b][c] = v1 - dp1[i][c][b];
                    dp2[i+1][b][c] = v2 - dp2[i][c][b] + (v1 - dp1[i][c][b]) * c;
                }
            }
        } else {
            rep(b, k) {
                mint v1 = 0, v2 = 0;
                for(int a = b + 1; a < k; a++) v1 += dp1[i][a][b], v2 += dp2[i][a][b];
                for(int c = b + 1; c < k; c++) {
                    dp1[i+1][b][c] += v1 - dp1[i][c][b];
                    dp2[i+1][b][c] += v2 - dp2[i][c][b] + (v1 - dp1[i][c][b]) * c;
                }
            }
        }
    }
    mint ans1, ans2;
    rep(i, k) rep(j, k) ans1 += dp1[n - 2][i][j], ans2 += dp2[n - 2][i][j];
    ans1 *= 2, ans2 *= 2;
    cout << ans1.val() << ' ' << ans2.val() << '\n';
}
0