結果
| 問題 | No.2899 Taffy Permutation |
| コンテスト | |
| ユーザー |
sea_water
|
| 提出日時 | 2026-10-07 16:20:31 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 779 bytes |
| 記録 | |
| コンパイル時間 | 3,768 ms |
| コンパイル使用メモリ | 352,064 KB |
| 実行使用メモリ | 9,928 KB |
| 最終ジャッジ日時 | 2026-10-07 16:20:58 |
| 合計ジャッジ時間 | 5,773 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 20 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,dp[2005][2005],q[2005][2005],ans;
string s;
int main(){
freopen("aspect.in","r",stdin);
freopen("aspect.out","w",stdout);
cin>>n;
cin>>s;
s=' '+s;
dp[0][0]=1;
q[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=i;j++){
q[i][j]+=q[i][j-1];
if(s[i]=='0'){
if(j){
dp[i][j]=q[i-1][j-1];
}
if(j>1)dp[i][j]+=dp[i-1][j-1]*1ll*(j-1)%mod;
dp[i][j]%=mod;
}
else{
dp[i][j]+=dp[i-1][j]*1ll*(i-j)%mod;
}
q[i][j]+=dp[i][j];
q[i][j]%=mod;
}
}
cout<<q[n][n]<<'\n';
return 0;
}
sea_water