結果

問題 No.1492 01文字列と転倒
ユーザー firiexpfiriexp
提出日時 2021-04-30 21:57:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 238 ms / 4,000 ms
コード長 1,307 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 100,224 KB
実行使用メモリ 11,460 KB
最終ジャッジ日時 2023-09-26 06:01:50
合計ジャッジ時間 3,875 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,612 KB
testcase_01 AC 3 ms
7,428 KB
testcase_02 AC 238 ms
11,460 KB
testcase_03 AC 216 ms
11,168 KB
testcase_04 AC 201 ms
11,132 KB
testcase_05 AC 164 ms
10,708 KB
testcase_06 AC 177 ms
10,808 KB
testcase_07 AC 185 ms
11,004 KB
testcase_08 AC 231 ms
11,448 KB
testcase_09 AC 3 ms
7,484 KB
testcase_10 AC 2 ms
5,372 KB
testcase_11 AC 3 ms
7,448 KB
testcase_12 AC 2 ms
7,428 KB
testcase_13 AC 2 ms
5,420 KB
testcase_14 AC 172 ms
11,040 KB
testcase_15 AC 3 ms
7,552 KB
testcase_16 AC 5 ms
7,784 KB
testcase_17 AC 166 ms
10,736 KB
testcase_18 AC 6 ms
7,808 KB
testcase_19 AC 2 ms
7,520 KB
testcase_20 AC 5 ms
7,696 KB
testcase_21 AC 135 ms
10,448 KB
testcase_22 AC 6 ms
7,800 KB
testcase_23 AC 4 ms
7,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int dp[2][101][10001];
int main() {
    int n, m;
    cin >> n >> m;
    dp[0][0][0] = 1;
    int bi = 0;
    for (int i = 0; i < 2*n; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= n*n; ++k) {
                dp[!bi][j][k] = 0;
            }
        }
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= n*n; ++k) {
                if(!dp[bi][j][k]) continue;
                if(j+1 <= n && 2*(j+1) >= i+1){
                    dp[!bi][j+1][k+i-j] += dp[bi][j][k]; // 0を追加
                    if(dp[!bi][j+1][k+i-j] >= m) dp[!bi][j+1][k+i-j] -= m;
                }
                if(2*j >= i+1){
                    dp[!bi][j][k] += dp[bi][j][k];
                    if(dp[!bi][j][k] >= m) dp[!bi][j][k] -= m;
                }
            }
        }
        bi ^= 1;
    }
    for (int k = 0; k <= n*n; ++k) {
        cout << dp[bi][n][k] << "\n";
    }

    return 0;
}
0