qinziao's blog

By qinziao, history, 7 weeks ago, In English
Your code here...
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dfs(int u)
{
    if(u==1)
    {
		ll minn=LONG_LONG_MAX;
		for(v|u->v)
		{
			minn=min(dfs(v),minn);
		}
		return value[u]+minn;
	}
	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<<dfs(1)<<endl;
	return 0;
}
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by qinziao (previous revision, new revision, compare).

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by qinziao (previous revision, new revision, compare).

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Is there any problem for my greedy strategy?

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by qinziao (previous revision, new revision, compare).