結果
| 問題 |
No.1492 01文字列と転倒
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-05-03 16:26:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 242 ms / 4,000 ms |
| コード長 | 1,338 bytes |
| コンパイル時間 | 861 ms |
| コンパイル使用メモリ | 94,892 KB |
| 実行使用メモリ | 11,676 KB |
| 最終ジャッジ日時 | 2024-07-22 06:58:49 |
| 合計ジャッジ時間 | 3,926 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1492.cc: No.1492 01文字列と転倒 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100;
const int MAX_N2 = MAX_N * 2;
const int MAX_NN = MAX_N * MAX_N;
/* typedef */
typedef long long ll;
/* global variables */
int dp[2][MAX_N + 1][MAX_NN + 1];
/* subroutines */
inline void addmod(int &a, int b, int m) { a = (a + b) % m; }
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
int n2 = n * 2, nn = n * n;
dp[0][0][0] = 1;
int cur = 0, nxt = 1;
for (int i = 0; i < n2; i++) {
memset(dp[nxt], 0, sizeof(dp[nxt]));
int maxj = min(i + 1, n);
for (int j = 0; j <= n; j++) {
int zj = i - j;
for (int k = 0; k <= nn; k++)
if (dp[cur][j][k]) {
// -> 0
if (zj < maxj)
addmod(dp[nxt][j][k + j], dp[cur][j][k], m);
// -> 1
if (zj > j && j < maxj)
addmod(dp[nxt][j + 1][k], dp[cur][j][k], m);
}
}
swap(cur, nxt);
}
for (int k = 0; k <= nn; k++) printf("%d\n", dp[cur][n][k]);
return 0;
}
tnakao0123