結果
| 問題 | No.3809 Count Bipartite Permutations |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-21 01:57:13 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 783 ms / 2,000 ms |
| + 254µs | |
| コード長 | 862 bytes |
| 記録 | |
| コンパイル時間 | 4,825 ms |
| コンパイル使用メモリ | 362,512 KB |
| 実行使用メモリ | 660,096 KB |
| 最終ジャッジ日時 | 2026-11-21 01:57:38 |
| 合計ジャッジ時間 | 15,837 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#define All(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using ll=long long;
const int mod=998244353;
signed main(){
IOS
int n,k;
cin>>n>>k;
int low=(1+n)*n/2,upp=n*n;
if(k<low||k>upp) return cout<<0<<'\n',0;
vector<vector<vector<ll>>> dp(2*n+1,vector<vector<ll>>(n+1,vector<ll>(upp+1)));
dp[0][0][0]=1;
for(int i=1;i<=2*n;++i){
for(int j=0;j<=i&&j<=n;++j){
for(int s=0;s<=upp;++s){
// i 作为较小的
if(s>=i&&j) (dp[i][j][s]+=dp[i-1][j-1][s-i])%=mod;
// i 作为较大的
if(j<i&&j<n) (dp[i][j][s]+=dp[i-1][j+1][s]*(j+1)%mod)%=mod;
}
}
}
ll n_=1;
for(int i=1;i<=n;++i) n_=n_*i%mod;
cout<<dp[2*n][0][k]*n_%mod<<'\n';
}