ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1018. Binary Apple Tree

How Q may be equal to N ?
Posted by Nazar Revutsky 15 Apr 2001 01:49
What I must show if Q=1?
What I must show if Q=N???
I think that Q<N!!!
Please help.
Re: How Q may be equal to N ?
Posted by Krzysztof Kapuscik 15 Apr 2001 20:32
> What I must show if Q=1?
> What I must show if Q=N???
> I think that Q<N!!!
> Please help.
>
Yeah - I think you're right. But I think it is a mistake in
problem description and my solution simply don't worry
about it. And for Q=1 you must leave only one branch. My
solution first build the tree and after that it cuts the
less valueable nodes (it mind branches are cutted also).
Correctness of your solution
Posted by Pavel Aksonov 16 Apr 2001 17:40
> Yeah - I think you're right. But I think it is a mistake
in
> problem description and my solution simply don't worry
> about it. And for Q=1 you must leave only one branch. My
> solution first build the tree and after that it cuts the
> less valueable nodes (it mind branches are cutted also).

Maybe I've misunderstood something:
Your solution for sample input with q=1 outputs "1".
But if we will cut branches <2 3>, <3 5>, <1 3> then we
preserve 10 apples (and it's more than 1)!!!
I don't undestand why answer "1" is right and "10" is
wrong. Could you please explain?
My solution
Posted by Nazar Revutsky 16 Apr 2001 21:18
My solution show 10 for sample test and q=1;

but for this test my program show 60 (i thing that 70 is OK)
5 2
1 2 10
2 3 50
1 4 30
4 5 40
To admins: please check correctness of author solution
Posted by Pavel Aksonov 16 Apr 2001 21:52
> My solution show 10 for sample test and q=1;
>
> but for this test my program show 60 (i thing that 70 is
OK)
> 5 2
> 1 2 10
> 2 3 50
> 1 4 30
> 4 5 40
Yes, as seems to me, author's solution show 60 and it's OK
for judge system. But right answer is really 70. I've
written correct solution but I've got WA.
I'm now searching for original solution to ask about it , this problem is temporary locked .
Posted by Marat Bakirov 17 Apr 2001 17:27
If you will haven't found it, I can propose my solution.
Posted by Pavel Aksonov 17 Apr 2001 19:33
>
Re: Correctness of your solution
Posted by Krzysztof Kapuscik 20 Apr 2001 18:34
I'm so sorry. I made a mistake in previous message. The
right answer is (total_apple - deleted_ apple) do in the
case that there should be only one node at end and there
are only one at start the number of deleted_apple = 0.
I'm really sorry.
If someone wants to see my code, please mail me at
saveman@zeus.polsl.gliwice.pl or
saveman@wp.pl