| 比赛 |
2025.12.13 |
评测结果 |
AEEEEEEEEE |
| 题目名称 |
勇者 |
最终得分 |
10 |
| 用户昵称 |
梦那边的没好TM |
运行时间 |
1.252 s |
| 代码语言 |
C++ |
内存使用 |
3.36 MiB |
| 提交时间 |
2025-12-13 11:58:21 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define cpy(a,b) copy(begin(a),end(a),begin(b))
#define ld long double
#define dot(x) fixed<<setprecision(x)
#define foru(a,b,c) for(ll a=b;a<=c;a++)
ll n,m,ans;
ll p[10];
bool g[10][10];
bool check(){
foru(s,1,n){
bool vis[10]={0};
queue<ll>q;
q.push(s);
vis[s]=1;
while(!q.empty()){
ll u=q.front();q.pop();
foru(v,1,n){
if(g[u][v]&&!vis[v]){
vis[v]=1;
q.push(v);
}
}
}
foru(i,1,n)if(!vis[i])return 0;
}
return 1;
}
void dfs(ll d){
if(d==m){
memset(g,0,sizeof(g));
foru(i,1,m)g[p[i-1]][p[i]]=1;
if(check())ans++;
return;
}
foru(v,1,n){
p[d+1]=v;
dfs(d+1);
}
}
int main(){
freopen("rotk.in" ,"r",stdin );
freopen("rotk.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
p[0]=1;
dfs(0);
cout<<ans;
return 0;
}