結果
問題 |
No.1492 01文字列と転倒
|
ユーザー |
![]() |
提出日時 | 2023-09-03 14:55:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,322 ms / 4,000 ms |
コード長 | 759 bytes |
コンパイル時間 | 5,566 ms |
コンパイル使用メモリ | 312,912 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-06-12 20:38:45 |
合計ジャッジ時間 | 17,170 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#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"; }