結果
| 問題 |
No.1492 01文字列と転倒
|
| コンテスト | |
| ユーザー |
hir355
|
| 提出日時 | 2021-04-30 21:59:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 502 ms / 4,000 ms |
| コード長 | 1,749 bytes |
| コンパイル時間 | 1,980 ms |
| コンパイル使用メモリ | 195,336 KB |
| 最終ジャッジ日時 | 2025-01-21 03:05:04 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
const long long INF_LL = 2000000000000000000LL;
const int INF = 2000000000;
const long long MOD = 1000000007;
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;P
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
if(a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, T b) {
if(a > b) {
a = b;
return 1;
}
return 0;
}
ll modpow(ll a, ll b, ll m) {
if(b == 0)
return 1;
ll t = modpow(a, b / 2, m);
if(b & 1) {
return (t * t % m) * a % m;
} else {
return t * t % m;
}
}
struct edge {
int to;
ll cost;
edge(int t, ll c) { to = t, cost = c; }
};
typedef vector<vector<edge>> graph;
modint dp[2][101][10001];
int main(){
int n, m;
cin >> n >> m;
modint::set_mod(m);
dp[0][0][0] = 1;
rep(i, n * 2){
rep(j, n + 1){
if(j > 0){
rep(k, n * n + 1) dp[(i + 1) & 1][j - 1][k] += dp[i & 1][j][k];
}
if(j < n){
REP(k, (i - j) / 2, n * n + 1) dp[(i + 1) & 1][j + 1][k] = dp[i & 1][j][k - (i - j) / 2];
}
rep(k, n * n + 1) dp[i & 1][j][k] = 0;
}
}
rep(i, n * n + 1){
cout << dp[0][0][i].val() << endl;
}
return 0;
}
hir355