結果

問題 No.1492 01文字列と転倒
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-09-03 14:55:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,219 ms / 4,000 ms
コード長 759 bytes
コンパイル時間 5,104 ms
コンパイル使用メモリ 310,088 KB
実行使用メモリ 19,004 KB
最終ジャッジ日時 2023-09-03 14:55:21
合計ジャッジ時間 15,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1,218 ms
19,004 KB
testcase_03 AC 1,077 ms
17,884 KB
testcase_04 AC 969 ms
17,064 KB
testcase_05 AC 808 ms
15,544 KB
testcase_06 AC 844 ms
15,808 KB
testcase_07 AC 922 ms
16,940 KB
testcase_08 AC 1,219 ms
18,880 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 873 ms
15,800 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 832 ms
15,616 KB
testcase_18 AC 15 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 10 ms
4,376 KB
testcase_21 AC 671 ms
13,852 KB
testcase_22 AC 14 ms
4,376 KB
testcase_23 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  ll n,m;cin>>n>>m;
  vc dp(n+1,vc<ll>(n*n+1,0)); dp[0][0]=1;
  rep(z,2*n){
    vc pre(n+1,vc<ll>(n*n+1,0)); swap(pre,dp);
    rep(i,n+1)rep(j,n*n+1)if(pre[i][j]!=0){
      if(j+(z-i)/2<=n*n&&i+1<=n)dp[i+1][j+(z-i)/2]=(dp[i+1][j+(z-i)/2]+pre[i][j])%m;
      if(i)dp[i-1][j]=(dp[i-1][j]+pre[i][j])%m;
    }
  }
  rep(i,n*n+1)cout<<dp[0][i]<<"\n";
}
0