Problem:
Score : 2000 points

Problem Statement

Given are integers N and K, and a prime number P. Find the number, modulo P, of directed graphs G with N vertices that satisfy below. Here, the vertices are distinguishable from each other.

G is a tournament, that is, G contains no duplicated edges or self-loops, and exactly one of the edges u\to v and v\to u exists for any two vertices u and v.

The in-degree of every vertex in G is at most K.

For any four distinct vertices a, b, c, and d in G, it is not the case that all of the six edges a\to b, b\to c, c\to a, a\to d, b\to d, and c\to d exist simultaneously.

Constraints

4 \leq N \leq 200

\frac{N-1}{2} \leq K \leq N-1

10^8<P<10^9

N and K are integers.

P is a prime number.

Input

Input is given from Standard Input in the following format:

N K P

Output

Print the number of directed graphs that satisfy the conditions, modulo P.

Sample Input 1

4 3 998244353

Sample Output 1

56

Among the 64 graphs with four vertices, 8 are isomorphic to the forbidden induced subgraphs, and the other 56 satisfy the conditions.

Sample Input 2

7 3 998244353

Sample Output 2

720

Sample Input 3

50 37 998244353

Sample Output 3

495799508

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
#define re register
int mod,fac[110],inv[110],f[110];
int main()
{
	re int n,k,ans=0;
	scanf("%d%d%d",&n,&k,&mod);
	fac[0]=1;
	for(re int i=1;i<=n;i++)fac[i]=1ll*i*fac[i-1]%mod;
	inv[1]=1;
	for(re int i=2;i<=n;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(re int i=n-k-1;i<n;i++)
	{
		re int k1=k-(n-i-1);
		for(re int i1=std::max(1,i-k1);i1<i&&i1<=k1;i1++)
		{
			re int i2=i-i1;
			memset(f,0,sizeof(f));
			for(re int i=0;i<i2;i++)if(i2-i<=k1&&i+i1<=k1)f[i]=1;
			for(re int i=1;i<i1;i++)
			{
				for(re int j=0;j<=i2;j++)
				{
					f[j+1]=(f[j]+f[j+1])%mod;
					if(!(i2-j+i<=k1&&j+i1-i<=k1))f[j]=0;
				}
			}
			for(re int j=0;j<=i2;j++)ans=(ans+1ll*inv[i+1]*f[j])%mod;
		//	printf("****%d %d %d %lld\n",i,i1,i2,1ll*ans*fac[n]%mod);
		}
	}
	if(k==n-1)ans++;
	ans=1ll*ans*fac[n]%mod;
	printf("%d\n",ans);
}