結果

問題 No.1492 01文字列と転倒
ユーザー RaffRaff
提出日時 2022-03-08 09:04:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 852 ms / 4,000 ms
コード長 1,008 bytes
コンパイル時間 1,479 ms
コンパイル使用メモリ 165,996 KB
実行使用メモリ 439,920 KB
最終ジャッジ日時 2023-09-30 14:12:18
合計ジャッジ時間 9,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 852 ms
439,856 KB
testcase_03 AC 780 ms
408,880 KB
testcase_04 AC 722 ms
378,436 KB
testcase_05 AC 616 ms
322,652 KB
testcase_06 AC 641 ms
335,920 KB
testcase_07 AC 698 ms
363,552 KB
testcase_08 AC 843 ms
439,920 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 642 ms
335,984 KB
testcase_15 AC 5 ms
5,280 KB
testcase_16 AC 20 ms
13,752 KB
testcase_17 AC 618 ms
322,764 KB
testcase_18 AC 22 ms
14,600 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 16 ms
11,296 KB
testcase_21 AC 518 ms
273,836 KB
testcase_22 AC 19 ms
13,756 KB
testcase_23 AC 11 ms
8,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, f, n) for (int i = (f); i < (n); i++)
#define rrep(i, f, n) for (int i = int(n) - 1; i >= f; i--)
typedef long long ll;
typedef pair<int, int> P;

template <typename T, typename U>
auto Sum(T a, U b) -> decltype(a + b)
{
    return a + b;
}

template <typename T, typename U>
inline bool amax(T &a, U b)
{
    if (b > a)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T, typename U>
inline bool amin(T &a, U b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int dp[101][101][11001] = {};

int main()
{
    int N, M;
    cin >> N >> M;

    rep(i, 0, N + 1) dp[0][i][0] = 1;

    rep(i, 1, N + 1) rep(j, 0, N + 1) rep(k, 0, N * N + 1)
    {
        if (0 < j)
            dp[i][j][k] += dp[i][j - 1][k];
        if (j < i && j <= k)
            dp[i][j][k] += dp[i - 1][j][k - j];
        dp[i][j][k] %= M;
    }
    rep(i, 0, N * N + 1) cout << dp[N][N][i] << endl;
}
0