QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#20438#2573. Two PermutationsAppleblue17#RE 0ms0kbC++17947b2022-02-16 09:59:122022-05-03 09:55:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-03 09:55:01]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-02-16 09:59:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long long N=110,mod=1e9+7,inv2=(mod+1)/2;

long long n,m;
long long dp[2][N][N*N],id;

long long gmod(long long &x){
	x%=mod;
}

int main(){
	cin>>n>>m;
	dp[0][0][0]=1;
	for(long long i=1;i<=n;i++){
		id^=1;
		memset(dp[id],0,sizeof(dp[id]));
		for(long long j=0;j<=n;j++){
			for(long long k=0;k<=m;k++){
				long long s=i-1-j,emp=n-(2*s+j);
				if(emp>0 && j+1<=n && k+i<=m) gmod(dp[id][j+1][k+i]+=dp[id^1][j][k]*emp%mod);
				if(emp>0) gmod(dp[id][j][k]+=dp[id^1][j][k]*emp%mod*(emp-1)%mod);
				if(s>0 && j+2<=n && k+2*i<=m) gmod(dp[id][j+2][k+2*i]+=dp[id^1][j][k]*s%mod*s%mod);
				if(s>0 && emp>0 && j+1<=n && k+i<=m) gmod(dp[id][j+1][k+i]+=dp[id^1][j][k]*s%mod*emp%mod*2%mod);
			}
		}
//		for(long long j=0;j<=n;j++){
//			for(long long k=0;k<=m;k++){
//				cout<<dp[i][j][k]<<" ";
//			}
//			cout<<endl;
//		}
//		cout<<endl;
	}
	cout<<dp[id][n][m];
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

2 4

output:


result: