結果

問題 No.1492 01文字列と転倒
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-19 00:31:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 742 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 204,600 KB
実行使用メモリ 19,244 KB
最終ジャッジ日時 2023-09-08 18:08:28
合計ジャッジ時間 36,188 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 TLE -
testcase_03 AC 3,722 ms
17,812 KB
testcase_04 AC 3,448 ms
16,984 KB
testcase_05 AC 2,890 ms
15,456 KB
testcase_06 AC 3,014 ms
15,948 KB
testcase_07 AC 3,275 ms
16,796 KB
testcase_08 TLE -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 3,019 ms
15,724 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 53 ms
4,380 KB
testcase_17 AC 2,875 ms
15,344 KB
testcase_18 AC 59 ms
4,376 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 37 ms
4,376 KB
testcase_21 AC 2,395 ms
13,812 KB
testcase_22 AC 53 ms
4,376 KB
testcase_23 AC 22 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){

    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> dp(N+1, vector<ll>(N*N+1));
    dp[0][0] = 1;
    for (int i=1; i<=N*2; i++){
        vector<vector<ll>> pd(N+1, vector<ll>(N*N+1));
        for (int j=0; j<=N; j++){
            for (int k=0; k<=N*N; k++){
                if (k+j<=N*N){
                    pd[j][k+j] += dp[j][k];
                    pd[j][k+j] %= M;
                }
                if (j+1<=N && i>=j*2+2){
                    pd[j+1][k] += dp[j][k];
                    pd[j+1][k] %= M;
                }
            }
        }
        swap(dp, pd);
    }

    for (int i=0; i<=N*N; i++) cout << dp[N][i] << endl;

    return 0;
}
0