代码:
#include<bits/stdc++.h>
#define ll long long
#define f(a,b,c) for(ll a=b;a<=c;++a)
using namespace std;
inline int read(){int f=1,x=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}return f*x;}
ll n,m,q,x,y,ans,tot;
ll a[5005][5005],bo[10000005];
void dfs(ll dep,ll sum,ll k)
{
sum++;
if(y==0)
{
ans=max(ans,sum);
return;
}
ll p=0;
f(i,1,n)
{
if(a[dep][i]&&!bo[i])
{
bo[i]=1;
dfs(i,sum,k-1);
bo[i]=0;
p=1;
}
}
if(!p)
{
ans=max(ans,sum);
return;
}
return;
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
n=read();
m=read();
q=read();
f(i,1,m)
{
x=read();
y=read();
a[x][y]=1;
a[y][x]=1;
}
f(i,1,q)
{
x=read();
y=read();
ans=0;
bo[x]=1;
dfs(x,0,y);
bo[x]=0;
tot+=ans;
// cout<<ans<<' ';
}
printf("%.2f",tot*1.00/n);
return 0;
}
有没有大佬帮帮蒟蒻啊