結果

問題 No.1492 01文字列と転倒
ユーザー sapphire__15sapphire__15
提出日時 2021-04-30 21:47:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,922 ms / 4,000 ms
コード長 2,125 bytes
コンパイル時間 2,882 ms
コンパイル使用メモリ 132,132 KB
実行使用メモリ 26,740 KB
最終ジャッジ日時 2023-09-26 05:45:35
合計ジャッジ時間 18,129 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1,917 ms
26,740 KB
testcase_03 AC 1,776 ms
25,420 KB
testcase_04 AC 1,637 ms
24,164 KB
testcase_05 AC 1,364 ms
21,768 KB
testcase_06 AC 1,424 ms
22,000 KB
testcase_07 AC 1,564 ms
23,368 KB
testcase_08 AC 1,922 ms
26,740 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1,435 ms
22,172 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 28 ms
4,384 KB
testcase_17 AC 1,362 ms
21,576 KB
testcase_18 AC 30 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 20 ms
4,380 KB
testcase_21 AC 1,122 ms
19,136 KB
testcase_22 AC 27 ms
4,380 KB
testcase_23 AC 13 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>
#include <numeric>
#include <iomanip>
#include <limits>
#include <random>
#include <unordered_map>

typedef int64_t ll;
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
typedef std::pair<double, double> Pdd;

#define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++)
#define all(_l) _l.begin(), _l.end()
#define rall(_l) _l.rbegin(), _l.rend()
#define MM << " " <<

template<typename _T>
using MaxHeap = std::priority_queue<_T>;
template<typename _T>
using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;

template<typename _T>
inline bool chmax(_T &_l, const _T _b) {
    if (_l < _b) {
        _l = _b;
        return true;
    }
    return false;
}
template<typename _T>
inline bool chmin(_T &_l, const _T _b) {
    if (_l > _b) {
        _l = _b;
        return true;
    }
    return false;
}

template<typename _T>
void vdeb(const std::vector<_T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename _T>
void vdeb(const std::vector<std::vector<_T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        // std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(n+1,vector<ll>(n*n+1)));
    dp[0][0][0] = 1;
    rip(i,n*2,0) {
        rip(j,n+1,0) rip(k,n*n+1,0) dp[1][j][k] = 0;
        rip(j,min(i+1,n+1),0) {
            rip(k,n*n+1,0) {
                dp[0][j][k] %= m;
                if(0 < j) dp[1][j-1][k] += dp[0][j][k];
                if(j+1 <= n && k + (i-j)/2 <= n*n) dp[1][j+1][k+(i-j)/2] += dp[0][j][k];
            }
        }
        swap(dp[0], dp[1]);
    }
    rip(i,n*n+1,0) {
        cout << dp[0][0][i]%m << endl;
    }
    // vdeb(dp);
}
0