結果

問題 No.1492 01文字列と転倒
ユーザー se1ka2se1ka2
提出日時 2021-04-30 21:37:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,249 ms / 4,000 ms
コード長 634 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 65,152 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-05-01 23:39:11
合計ジャッジ時間 28,358 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
19,404 KB
testcase_01 AC 22 ms
19,328 KB
testcase_02 AC 3,249 ms
19,444 KB
testcase_03 AC 3,009 ms
19,324 KB
testcase_04 AC 2,776 ms
19,428 KB
testcase_05 AC 2,312 ms
19,216 KB
testcase_06 AC 2,412 ms
19,352 KB
testcase_07 AC 2,620 ms
19,456 KB
testcase_08 AC 3,191 ms
19,384 KB
testcase_09 AC 25 ms
19,404 KB
testcase_10 AC 18 ms
19,272 KB
testcase_11 AC 22 ms
19,456 KB
testcase_12 AC 23 ms
19,396 KB
testcase_13 AC 19 ms
19,396 KB
testcase_14 AC 2,380 ms
19,452 KB
testcase_15 AC 44 ms
19,404 KB
testcase_16 AC 105 ms
19,268 KB
testcase_17 AC 2,287 ms
19,328 KB
testcase_18 AC 111 ms
19,244 KB
testcase_19 AC 32 ms
19,456 KB
testcase_20 AC 88 ms
19,272 KB
testcase_21 AC 1,932 ms
19,248 KB
testcase_22 AC 109 ms
19,272 KB
testcase_23 AC 72 ms
19,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

ll dp[10002][102];
ll d[10002][102];

int main()
{
    int n;
    ll m;
    cin >> n >> m;
    dp[0][0] = 1;
    for(int i = 1; i <= n * 2; i++){
        for(int j = 0; j <= n * n; j++){
            for(int k = 0; k <= n; k++) d[j][k] = 0;
        }
        for(int j = 0; j <= n * n; j++){
            for(int k = 0; k <= n; k++) d[j + k][k] = (d[j + k][k] + dp[j][k]) % m;
            for(int k = 0; (k + 1) * 2 <= i; k++) d[j][k + 1] = (d[j][k + 1] + dp[j][k]) % m;
        }
        swap(dp, d);
    }
    for(int j = 0; j <= n * n; j++) cout << dp[j][n] << endl;
}
0