Search found 2 matches

by kakaroto2
Tue Dec 10, 2013 3:22 am
Forum: Volume 106 (10600-10699)
Topic: 10672 - Marbles on a tree
Replies: 8
Views: 6057

Re: 10672 - Marbles on a tree

brianfry713 wrote:Input:

Code: Select all

4
1 2 1 2
2 1 1 3
3 1 1 4
4 0 0
AC output 3
thx!
I've already figure out that my algo will fail when the depth of the tree is more than 3.
So I compromise to Dfs,and then Ac in 25ms.
Thanks again for brianfry713's test sample!
by kakaroto2
Sat Dec 07, 2013 5:35 am
Forum: Volume 106 (10600-10699)
Topic: 10672 - Marbles on a tree
Replies: 8
Views: 6057

Re: 10672 - Marbles on a tree

Here's my code.
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;

int main()
{
int n;
while( ~scanf("%d",&n)&&n )
{
int father,value,nkid;
int iskid[10005]={0};
int marble[10005]={0};
vector<vector<int> >tree;
tree.clear() , tree.resize(n);
for(int i=0;i<n;i ...

Go to advanced search