Update 5723.cpp

This time AC.
This commit is contained in:
Kirigaya Kazuto 2016-09-19 11:35:31 +08:00 committed by GitHub
parent adeccbcc64
commit 48f40cd2f8

View File

@ -30,6 +30,7 @@ int findfather(int x)
return father[x]==x?x:father[x]=findfather(father[x]); return father[x]==x?x:father[x]=findfather(father[x]);
} }
/// Global For DFS
LL totalans; LL totalans;
LL dfs(int index) LL dfs(int index)
@ -40,9 +41,10 @@ LL dfs(int index)
LL nextans=0; LL nextans=0;
for(int i=0;i<sz;i++) for(int i=0;i<sz;i++)
{ {
if(!vis[vec[index].at(i).first]) int tt=vec[index].at(i).first;
if(!vis[tt])
{ {
nextans=dfs(vec[index].at(i).first); nextans=dfs(tt);
ksum+=nextans; ksum+=nextans;
totalans+=(n-nextans)*nextans*vec[index].at(i).second; totalans+=(n-nextans)*nextans*vec[index].at(i).second;
} }
@ -105,7 +107,7 @@ int main()
totalans=0; totalans=0;
dfs(b); dfs(b);
double tans=n*(n-1)/2.0; double tans=0.5*n*(n-1);
/// Use Long Long? /// Use Long Long?
printf("%I64d %.2lf\n",sum,(double)totalans/tans); printf("%I64d %.2lf\n",sum,(double)totalans/tans);
} }