結果

問題 No.1492 01文字列と転倒
ユーザー hir355hir355
提出日時 2021-04-30 21:59:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 323 ms / 4,000 ms
コード長 1,749 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 201,524 KB
実行使用メモリ 11,572 KB
最終ジャッジ日時 2023-09-26 06:03:52
合計ジャッジ時間 6,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,432 KB
testcase_01 AC 5 ms
11,308 KB
testcase_02 AC 322 ms
11,288 KB
testcase_03 AC 297 ms
11,300 KB
testcase_04 AC 275 ms
11,376 KB
testcase_05 AC 232 ms
11,304 KB
testcase_06 AC 243 ms
11,572 KB
testcase_07 AC 263 ms
11,228 KB
testcase_08 AC 323 ms
11,236 KB
testcase_09 AC 6 ms
11,308 KB
testcase_10 AC 5 ms
11,240 KB
testcase_11 AC 5 ms
11,240 KB
testcase_12 AC 5 ms
11,244 KB
testcase_13 AC 5 ms
11,224 KB
testcase_14 AC 243 ms
11,252 KB
testcase_15 AC 6 ms
11,228 KB
testcase_16 AC 11 ms
11,436 KB
testcase_17 AC 234 ms
11,228 KB
testcase_18 AC 12 ms
11,300 KB
testcase_19 AC 5 ms
11,288 KB
testcase_20 AC 9 ms
11,440 KB
testcase_21 AC 195 ms
11,288 KB
testcase_22 AC 10 ms
11,284 KB
testcase_23 AC 7 ms
11,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
const long long INF_LL = 2000000000000000000LL;
const int INF = 2000000000;
const long long MOD = 1000000007;
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;P
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

typedef vector<vector<edge>> graph;

modint dp[2][101][10001];

int main(){
    int n, m;
    cin >> n >> m;
    modint::set_mod(m);
    dp[0][0][0] = 1;
    rep(i, n * 2){
        rep(j, n + 1){
            if(j > 0){
                rep(k, n * n + 1) dp[(i + 1) & 1][j - 1][k] += dp[i & 1][j][k];
            }
            if(j < n){
                REP(k, (i - j) / 2, n * n + 1) dp[(i + 1) & 1][j + 1][k] = dp[i & 1][j][k - (i - j) / 2];
            }
            rep(k, n * n + 1) dp[i & 1][j][k] = 0;
        }
    }
    rep(i, n * n + 1){
        cout << dp[0][0][i].val() << endl;
    }
    return 0;
}
0