結果

問題 No.1492 01文字列と転倒
ユーザー fumofumofunifumofumofuni
提出日時 2021-04-30 22:35:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,641 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 200,052 KB
実行使用メモリ 19,464 KB
最終ジャッジ日時 2023-09-26 06:54:59
合計ジャッジ時間 10,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
19,148 KB
testcase_01 AC 32 ms
19,140 KB
testcase_02 RE -
testcase_03 AC 702 ms
19,280 KB
testcase_04 AC 677 ms
19,140 KB
testcase_05 AC 602 ms
19,388 KB
testcase_06 AC 641 ms
19,208 KB
testcase_07 AC 664 ms
19,136 KB
testcase_08 RE -
testcase_09 AC 46 ms
19,208 KB
testcase_10 AC 19 ms
19,424 KB
testcase_11 AC 34 ms
19,124 KB
testcase_12 AC 36 ms
19,280 KB
testcase_13 AC 23 ms
19,136 KB
testcase_14 AC 659 ms
19,212 KB
testcase_15 AC 96 ms
19,204 KB
testcase_16 AC 165 ms
19,336 KB
testcase_17 AC 612 ms
19,120 KB
testcase_18 AC 169 ms
19,136 KB
testcase_19 AC 71 ms
19,264 KB
testcase_20 AC 153 ms
19,384 KB
testcase_21 AC 613 ms
19,464 KB
testcase_22 AC 174 ms
19,204 KB
testcase_23 AC 132 ms
19,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}
ll dp[101][10010];//すでに0がiこ出ていて、転倒数がKである
int main(){
  ll n,m;cin >> n >>m;
  rep(i,101)rep(j,10010)dp[i][j]=0;
  dp[0][0]=1;
  ll ndp[101][10010];
  rep(i,2*n){
    rep(j,101)rep(k,10010)ndp[j][k]=0;
    rep(j,101){
      rep(k,10010){
        if(!dp[j][k])continue;
        if(j+1<=n)ndp[j+1][k]+=dp[j][k];ndp[j+1][k]%=m;
        if(j<i-j+1)continue;
        if(i-j+1<=n)ndp[j][k+n-j]+=dp[j][k];ndp[j][k+n-j]%=m;
      }
    }
    /*rep(j,3)rep(k,3){
      cout << ndp[j][k] <<" ";
    }
    cout << endl;*/
    swap(dp,ndp);
  }
  rep(j,n*n+1){
    ll ans=0;
    rep(k,101){
      ans+=dp[k][j];
      ans%=m;
    }
    cout << ans <<endl;
  }
} 
0