problem/1997/D

Revision en4, by qinziao, 2024-10-04 05:45:08
Your code here...
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dfs(int u)
{
	if(son[u]==0)
		return value[u];
	if(son[u]==1)
		return (value[u]+dfs(v))>>1;
	if(son[u]>1)
	{
		ll minn=LONG_LONG_MAX;
		for(v|u->v)
		{
			minn=min(dfs(v),minn);
		}
		return minn;
	}
}
int main()
{
	cout<<value[1]+dfs(1)<<endl;
	return 0;
}
Tags dfs and similar, greedy, tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English qinziao 2024-10-04 06:18:25 137
en4 English qinziao 2024-10-04 05:45:08 8 Tiny change: ' ll minn=MAX_LONG_LONG;\n for(v' -> ' ll minn=LONG_LONG_MAX;\n for(v'
en3 English qinziao 2024-10-04 05:32:34 5 Tiny change: '-\n~~~~~\nYour code here...\n\n#include' -> '~~~~~\nYour code here...\n#include'
en2 English qinziao 2024-10-04 05:31:54 40
en1 English qinziao 2024-10-04 05:30:55 365 Initial revision (published)