結果
| 問題 | No.2899 Taffy Permutation |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-25 19:25:28 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 618 bytes |
| コンパイル時間 | 2,401 ms |
| コンパイル使用メモリ | 161,872 KB |
| 実行使用メモリ | 66,228 KB |
| 最終ジャッジ日時 | 2024-09-25 19:25:34 |
| 合計ジャッジ時間 | 3,881 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
const int mod = 998244353;
int n;
string a;
long long s[N][N], dp[N][N];
int main(){
cin >> n >> a;
a = ' ' + a;
dp[0][n] = 1;
for(int j = 0; j <= n; j++) s[0][j] = 1;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= n; j++){
if(a[i] == '0'){
dp[i][j] = s[i - 1][j];
}
else{
dp[i][j] = dp[i - 1][j + 1];
}
}
for(int j = n; j >= 0; j--){
s[i][j] = s[i][j + 1] + dp[i][j];
while(s[i][j] >= mod) s[i][j] -= mod;
}
}
cout << (dp[n][0] + dp[n][1]) % mod;
return 0;
}
vjudge1