結果

問題 No.1492 01文字列と転倒
ユーザー fumofumofunifumofumofuni
提出日時 2021-04-30 22:37:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 763 ms / 4,000 ms
コード長 1,604 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 199,900 KB
実行使用メモリ 19,424 KB
最終ジャッジ日時 2023-09-26 06:57:36
合計ジャッジ時間 11,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
19,140 KB
testcase_01 AC 28 ms
19,192 KB
testcase_02 AC 716 ms
19,280 KB
testcase_03 AC 711 ms
19,120 KB
testcase_04 AC 702 ms
19,116 KB
testcase_05 AC 662 ms
19,112 KB
testcase_06 AC 688 ms
19,128 KB
testcase_07 AC 715 ms
19,120 KB
testcase_08 AC 763 ms
19,132 KB
testcase_09 AC 46 ms
19,212 KB
testcase_10 AC 20 ms
19,164 KB
testcase_11 AC 36 ms
19,112 KB
testcase_12 AC 35 ms
19,280 KB
testcase_13 AC 24 ms
19,264 KB
testcase_14 AC 672 ms
19,212 KB
testcase_15 AC 107 ms
19,424 KB
testcase_16 AC 187 ms
19,136 KB
testcase_17 AC 658 ms
19,208 KB
testcase_18 AC 195 ms
19,124 KB
testcase_19 AC 78 ms
19,120 KB
testcase_20 AC 175 ms
19,208 KB
testcase_21 AC 616 ms
19,120 KB
testcase_22 AC 195 ms
19,416 KB
testcase_23 AC 142 ms
19,208 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;
        }
      }
    }
    swap(dp,ndp);
  }
  rep(j,n*n+1){
    ll ans=0;
    rep(k,101){
      ans+=dp[k][j];
      ans%=m;
    }
    cout << ans <<endl;
  }
} 
0