結果
| 問題 |
No.2899 Taffy Permutation
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-25 20:44:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 2,663 ms |
| コンパイル使用メモリ | 247,412 KB |
| 実行使用メモリ | 34,928 KB |
| 最終ジャッジ日時 | 2024-09-25 20:44:56 |
| 合計ジャッジ時間 | 3,805 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 7 |
ソースコード
#include <bits/stdc++.h>
#define _1 (__int128)1
using namespace std;
using ll = long long;
void FileIO (const string s) {
freopen(string(s + ".in").c_str(), "r", stdin);
freopen(string(s + ".out").c_str(), "w", stdout);
}
const int N = 2010, mod = 998244353;
int n, dp[N][N], sum[N][N];
string s;
signed main () {
ios::sync_with_stdio(0), cin.tie(0);
// FileIO("");
cin >> n >> s, s = " " + s;
for (int i = 1; i <= n; i++) sum[0][i] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= n; j++) {
if (s[i] == '0')
dp[i][j] = ((1ll * dp[i - 1][j] * (n - i - j + 1) + sum[i - 1][j + 1]) % mod + mod) % mod;
else
dp[i][j] = 1ll * (j + 1) * dp[i - 1][j + 1] % mod;
}
for (int j = n; j; j--) sum[i][j] = (sum[i][j + 1] + dp[i][j]) % mod;
}
cout << dp[n][0];
return 0;
}
vjudge1