QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129232 | #2573. Two Permutations | xlao | WA | 2ms | 3888kb | C++14 | 664b | 2023-07-22 11:14:00 | 2023-07-22 11:14:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=60, mod=998244353;
inline void _Add(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int n,m,f[N][N][N*N];
int main()
{
scanf("%d %d",&n,&m);
f[0][0][0]=1;
for(int i=0;i<n;++i)
{
for(int j=0;j<=i;++j)
{
for(int k=0;k<=i*i;++k)
{
_Add(f[i+1][j+1][k+i+1], f[i][j][k]);
_Add(f[i+1][j][k], f[i][j][k]);
_Add(f[i+1][j+1][k+i+1], 2ll*f[i][j][k]*(i-j)%mod);
_Add(f[i+1][j+2][k+i+1+i+1], 1ll*f[i][j][k]*(i-j)%mod*(i-j)%mod);
}
}
}
int ans=0;
for(int k=m;k<=n*n;++k) _Add(ans, f[n][n][k]);
for(int i=1;i<=n;++i) ans = 1ll*ans*i%mod;
printf("%d\n",ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3696kb
input:
2 4
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3888kb
input:
3 7
output:
30
result:
wrong answer 1st numbers differ - expected: '12', found: '30'