QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#88561 | #2573. Two Permutations | s8194272 | WA | 10ms | 12504kb | C++14 | 1.9kb | 2023-03-16 15:34:57 | 2023-03-16 15:35:00 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<random>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define pb(x) push_back(x)
#define lowbit(x) ((x)&(-(x)))
#define fan(x) ((((x)-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
#define SZ(x) ((int)(x.size()))
#define INF 0x3f3f3f3f
using namespace std;
inline int read()
{
int ans=0,f=1;
char c=getchar();
while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
return ans*f;
}
inline void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x/10) write(x/10);
putchar((char)(x%10)+'0');
}
template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a<b?a:b;}
template<typename T,typename TT> inline T Max(T a,TT b){return a<b?b:a;}
const int N=105,mod=998244353;
int n,k,f[2][N][N*N];
signed main()
{
n=read();k=read();
int now=0;
f[0][0][0]=1;
for(int i=0;i<n;++i)
{
memset(f[now^1],0,sizeof(f[now^1]));
for(int j=0;j<=i;++j)
for(int p=0;p<=k;++p)
if(f[now][j][p])
{
if(j+1<=i) f[now^1][j+2][p]=(f[now^1][j+2][p]+f[now][j][p]*1ll*(i-j)%mod*(i-j))%mod;
if(p+i+1<=k) f[now^1][j+1][p+n-i]=(f[now^1][j+1][p+n-i]+f[now][j][p]*1ll*(i-j)%mod*(n-i)*2)%mod;
if(p+(i+1)*2<=k&&n-i-1>=0) f[now^1][j][p+(n-i)*2]=(f[now^1][j][p+(n-i)*2]+f[now][j][p]*1ll*(n-i)%mod*(n-i-1))%mod;
if(n-i*2+j>=0) f[now^1][j+1][p+n-i]=(f[now^1][j+1][p+n-i]+f[now][j][p]*1ll*(n-i*2+j))%mod;
}
now^=1;
}
write(f[now][n][k]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 12240kb
input:
2 4
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 10ms
memory: 12504kb
input:
3 7
output:
12
result:
ok 1 number(s): "12"
Test #3:
score: 0
Accepted
time: 2ms
memory: 12496kb
input:
4 10
output:
24
result:
ok 1 number(s): "24"
Test #4:
score: -100
Wrong Answer
time: 8ms
memory: 12320kb
input:
4 14
output:
288
result:
wrong answer 1st numbers differ - expected: '96', found: '288'