結果

問題 No.1513 simple 門松列 problem
ユーザー chocoruskchocorusk
提出日時 2021-05-21 21:48:03
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 120 ms / 3,000 ms
コード長 1,891 bytes
コンパイル時間 3,861 ms
コンパイル使用メモリ 188,828 KB
実行使用メモリ 132,480 KB
最終ジャッジ日時 2024-04-18 15:04:15
合計ジャッジ時間 5,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
132,352 KB
testcase_01 AC 35 ms
132,480 KB
testcase_02 AC 114 ms
132,352 KB
testcase_03 AC 35 ms
132,352 KB
testcase_04 AC 35 ms
132,316 KB
testcase_05 AC 35 ms
132,444 KB
testcase_06 AC 36 ms
132,444 KB
testcase_07 AC 34 ms
132,224 KB
testcase_08 AC 37 ms
132,480 KB
testcase_09 AC 35 ms
132,444 KB
testcase_10 AC 34 ms
132,480 KB
testcase_11 AC 35 ms
132,480 KB
testcase_12 AC 34 ms
132,224 KB
testcase_13 AC 34 ms
132,352 KB
testcase_14 AC 114 ms
132,480 KB
testcase_15 AC 114 ms
132,480 KB
testcase_16 AC 120 ms
132,440 KB
testcase_17 AC 99 ms
132,224 KB
testcase_18 AC 51 ms
132,352 KB
testcase_19 AC 35 ms
132,352 KB
testcase_20 AC 44 ms
132,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint dp[202][202][202];
mint dps[202][202][202];
mint dp1[202][202][202], dps1[202][202][202];
int main()
{
    int n, k; cin>>n>>k;
    for(int i=0; i<k; i++) for(int j=0; j<k; j++){
        if(i==j) continue;
        dp[2][i][j]=1;
        dps[2][i][j]=i+j;
        dp1[2][i+1][j]=dp1[2][i][j]+dp[2][i][j];
        dps1[2][i+1][j]=dps1[2][i][j]+dps[2][i][j];
    }
    for(int i=2; i<n; i++){
        for(int j=0; j<k; j++){
            for(int l=0; l<k; l++){
                if(j==l) continue;
                if(j<l){
                    dp[i+1][j][l]+=dp1[i][k][j]-dp1[i][j+1][j]-dp[i][l][j];
                    dps[i+1][j][l]+=dps1[i][k][j]-dps1[i][j+1][j]-dps[i][l][j]+(dp1[i][k][j]-dp1[i][j+1][j]-dp[i][l][j])*mint(l);
                }else{
                    dp[i+1][j][l]+=dp1[i][j][j]-dp[i][l][j];
                    dps[i+1][j][l]+=dps1[i][j][j]-dps[i][l][j]+(dp1[i][j][j]-dp[i][l][j])*mint(l);
                }
                dp1[i+1][j+1][l]=dp1[i+1][j][l]+dp[i+1][j][l];
                dps1[i+1][j+1][l]=dps1[i+1][j][l]+dps[i+1][j][l];
            }
        }
    }
    mint ans1=0, ans2=0;
    for(int i=0; i<k; i++) for(int j=0; j<k; j++) ans1+=dp[n][i][j], ans2+=dps[n][i][j];
    cout<<ans1.val()<<" "<<ans2.val()<<endl;
    return 0;
}
0