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 1056. Centers of the Net

Maybe test data is weak?(-)
Posted by tiancaihb 6 Aug 2009 14:40
For data:5 5 4 5 1
I know it's illegal according to the statement,but it's the only one I can find now. However,I believe there is an "legal" one which may make some AC prog wrong ans!
My AC prog says 5 4! I used bfs twice,and I didn't sort the 2 numbers! Perhaps there is no data figures out this problem.
btw,I fixed my prog at once.Sorry for my poor English.

Edited by author 06.08.2009 14:41

Edited by author 06.08.2009 14:47
Re: Maybe test data is weak?(-)
Posted by tiancaihb 6 Aug 2009 14:58
Sorry,but now I know maybe there isn't a "legal" data that makes error.
I can't prove it well,but it's true:when use 2bfs,you needn't sort 2 num.
See:
Divide the tree into 2 parts,L and R.
The answer,if 2 num,must be in the longer part.Let's say it's on the right.
First you bfs to right,then bfs to leftmost.
When you follow the longest chain back again,you are going to right side.
If the data is legal,part R is in inscend(I don't know how to spell) order.So ans num1<ans num2.
so you needn't sort them at all!