結果

問題 No.1492 01文字列と転倒
ユーザー sgswsgsw
提出日時 2021-05-03 14:36:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,405 ms / 4,000 ms
コード長 1,840 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 202,868 KB
実行使用メモリ 20,472 KB
最終ジャッジ日時 2023-09-29 10:38:02
合計ジャッジ時間 31,428 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
20,220 KB
testcase_01 AC 109 ms
20,280 KB
testcase_02 AC 2,405 ms
20,224 KB
testcase_03 AC 2,348 ms
20,408 KB
testcase_04 AC 2,290 ms
20,324 KB
testcase_05 AC 2,194 ms
20,408 KB
testcase_06 AC 2,228 ms
20,348 KB
testcase_07 AC 2,278 ms
20,268 KB
testcase_08 AC 2,395 ms
20,360 KB
testcase_09 AC 180 ms
20,376 KB
testcase_10 AC 61 ms
20,408 KB
testcase_11 AC 133 ms
20,228 KB
testcase_12 AC 133 ms
20,460 KB
testcase_13 AC 85 ms
20,444 KB
testcase_14 AC 2,219 ms
20,216 KB
testcase_15 AC 438 ms
20,368 KB
testcase_16 AC 816 ms
20,216 KB
testcase_17 AC 2,208 ms
20,436 KB
testcase_18 AC 839 ms
20,444 KB
testcase_19 AC 323 ms
20,472 KB
testcase_20 AC 748 ms
20,440 KB
testcase_21 AC 2,106 ms
20,212 KB
testcase_22 AC 823 ms
20,224 KB
testcase_23 AC 653 ms
20,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ALL(a) a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(a) a.begin(),a.end()
template<class T> ostream& operator << (ostream &s, vector<T> &P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template <class T>bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
using P  = pair<int,int>;
const int inf = 1e18;

int N,M;
const int MAXN = 100;
const int MAXINV = MAXN * MAXN;
vector<vector<int>> DP0(MAXN + 10,vector<int>(MAXINV + MAXN + 10,0));
vector<vector<int>> DP1(MAXN + 10,vector<int>(MAXINV + MAXN + 10,0));

signed main(){
    cin>>N>>M;
    DP0[0][0] = 1;

    rep(i,2*N){
        if (i % 2 == 0){
            rep(dif,MAXN + 1)rep(inv,MAXINV + 1){
                DP1[dif][inv] = 0;
            }
            rep(dif,MAXN + 1)rep(inv,MAXINV + 1){
                int v = DP0[dif][inv] % M;
                DP1[dif + 1][inv + (i - dif) / 2] += v;
                if (dif > 0)DP1[dif - 1][inv] += v;
            }
        }
        else{
            rep(dif,MAXN + 1)rep(inv,MAXINV + 1){
                DP0[dif][inv] = 0;
            }
            rep(dif,MAXN + 1)rep(inv,MAXINV + 1){
                int v = DP1[dif][inv] % M;
                DP0[dif + 1][inv + (i - dif) / 2] += v;
                if (dif > 0)DP0[dif - 1][inv] += v;
            }
        }
    }
  
    rep(i,N * N + 1){
        int res = DP0[0][i] % M;
        if (res < 0){res += M;}
        cout << res << endl;
    }
    return 0;
}
0