結果

問題 No.1492 01文字列と転倒
ユーザー tarattata1tarattata1
提出日時 2021-04-30 22:19:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 653 ms / 4,000 ms
コード長 1,992 bytes
コンパイル時間 2,936 ms
コンパイル使用メモリ 153,220 KB
実行使用メモリ 21,652 KB
最終ジャッジ日時 2023-09-26 06:24:24
合計ジャッジ時間 9,309 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,644 KB
testcase_01 AC 2 ms
7,628 KB
testcase_02 AC 653 ms
21,644 KB
testcase_03 AC 584 ms
21,560 KB
testcase_04 AC 541 ms
21,184 KB
testcase_05 AC 439 ms
20,476 KB
testcase_06 AC 477 ms
20,552 KB
testcase_07 AC 521 ms
20,972 KB
testcase_08 AC 647 ms
21,652 KB
testcase_09 AC 2 ms
7,704 KB
testcase_10 AC 2 ms
5,628 KB
testcase_11 AC 2 ms
7,708 KB
testcase_12 AC 2 ms
7,708 KB
testcase_13 AC 2 ms
5,688 KB
testcase_14 AC 473 ms
20,480 KB
testcase_15 AC 3 ms
7,728 KB
testcase_16 AC 10 ms
10,108 KB
testcase_17 AC 441 ms
20,324 KB
testcase_18 AC 10 ms
10,428 KB
testcase_19 AC 3 ms
7,800 KB
testcase_20 AC 8 ms
10,084 KB
testcase_21 AC 349 ms
19,560 KB
testcase_22 AC 10 ms
10,120 KB
testcase_23 AC 5 ms
7,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <ctime>
#pragma warning(disable:4996) 

#define ATCODER
#ifdef ATCODER
#include <atcoder/all>
#endif

typedef long long ll;
typedef unsigned long long ull;
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
#ifdef ATCODER
using namespace atcoder;
#endif

ll dp[2][205][10005];

void solve()
{
    int n; ll M;
    scanf("%d%lld", &n, &M);
    int pre = 0, cur = 1;
    dp[0][0][0] = 1;
    for (int i = 0; i < n * 2; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n * n; k++) {
                dp[cur][j][k] = 0;
            }
        }
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n * n; k++) {
                if (dp[pre][j][k] == 0) continue;

                if (i - j + 1 <= n) {
                    int k2 = k + j;
                    dp[cur][j][k2] = (dp[cur][j][k2] + dp[pre][j][k]) % M;
                }
                if (j + 1 <= i - j) {
                    int k2 = k;
                    dp[cur][j+1][k2] = (dp[cur][j+1][k2] + dp[pre][j][k]) % M;
                }
            }
        }
        swap(pre, cur);
    }

    for (int k = 0; k <= n * n; k++) {
        ll ans = 0;
        for (int j = 0; j <= n; j++) {            
            ans = (ans + dp[pre][j][k]) % M;            
        }
        printf("%lld\n", ans);
    }          

    return;
}


int main()
{
#if 1
    solve();
#else
    int T, t;
    scanf("%d", &T);
    for (t = 0; t < T; t++) {
        //cout << "Case #" << t + 1 << ": ";
        solve();
    }
#endif
    return 0;
}
0