結果
問題 | No.1492 01文字列と転倒 |
ユーザー |
![]() |
提出日時 | 2023-01-19 21:24:33 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 928 ms / 4,000 ms |
コード長 | 957 bytes |
コンパイル時間 | 2,226 ms |
コンパイル使用メモリ | 142,972 KB |
実行使用メモリ | 19,160 KB |
最終ジャッジ日時 | 2024-06-22 12:26:12 |
合計ジャッジ時間 | 9,596 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; int main() { int N, M; cin >> N >> M; ll dp[N + 1][N * N + 1]; memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (int i = 0; i < 2 * N; ++i) { ll temp[N + 1][N * N + 1]; memset(temp, 0, sizeof(temp)); for (int zc = 0; zc <= N; ++zc) { int oc = i - zc; if (oc > zc) continue; for (int k = 0; k < N * N; ++k) { if (oc + 1 <= zc) { temp[zc][k] += dp[zc][k]; temp[zc][k] %= M; } if (zc + 1 <= N) { temp[zc + 1][k + oc] += dp[zc][k]; temp[zc + 1][k + oc] %= M; } } } memcpy(dp, temp, sizeof(temp)); } for (int k = 0; k <= N * N; ++k) { cout << dp[N][k] << endl; } return 0; }