比赛 期末考试2 评测结果 TTTTTTTTTT
题目名称 数图 最终得分 0
用户昵称 zhyn 运行时间 51.004 s
代码语言 C++ 内存使用 3.37 MiB
提交时间 2026-02-10 11:25:21
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;

#define ll long long
int n;
bool num[600][600];
int dis[600];
ll ans=0;
const ll mod=1e9+7;

ll mode(ll x){
	if(x>=mod){
		x-=mod;
	}
	return x;
}

void dfs(int u){
	if(u==n+1){
		ans++;
		ans=mode(ans);
		return;
	}
	for(int i=1;i<=n;i++){
		if(i==u){
			continue;
		}
		if(dis[i]==2){
			continue;
		}
		for(int j=i+1;j<=n;j++){
			if(j==u){
				continue;
			}
			if(dis[j]==2){
				continue;
			}
			dis[i]++,dis[j]++;
			dfs(u+1);
			dis[i]--,dis[j]--;
		}
	}
}

int main(){
	
	freopen("grafy.in","r",stdin);
	freopen("grafy.out","w",stdout);
	
	
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	
	dfs(1);
	
	cout<<ans<<"\n";
	
	return 0;
}