結果

問題 No.1492 01文字列と転倒
ユーザー zuminzumin
提出日時 2021-04-30 23:26:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,197 bytes
コンパイル時間 6,212 ms
コンパイル使用メモリ 274,972 KB
実行使用メモリ 818,176 KB
最終ジャッジ日時 2024-07-19 03:36:56
合計ジャッジ時間 8,346 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other MLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/algorithm/string.hpp>

using namespace std;
using namespace atcoder;

typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<vector<ll>>> dp=vector<vector<vector<ll>>>(2*n+1,vector<vector<ll>>(2*n+1,vector<ll>(n*n+1,0)));
    dp[0][0][0]=1;

    REP(i,2*n){
        REP(j,2*n+1){
            REP(k,n*n+1){
                if(j>=1&&((i^(j-1))&1)==0&&(2*k>=(i-j+1))){
                    dp[i+1][j][k]+=dp[i][j-1][k-(i-j+1)/2];
                    dp[i+1][j][k]%=m;
                }
                if(j<=i){
                    dp[i+1][j][k]+=dp[i][j+1][k];
                    dp[i+1][j][k]%=m;
                }
                
            }
        }
    }
    REP(k,n*n+1){
        cout<<dp[2*n][0][k]<<endl;
    }
}
0