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

Idea O(N)
Posted by Felix_Mate 4 Aug 2015 12:55
I got AC! It's nice problem!
My algo works at O(3*N)=O(N).
1)BFS from any vertex and find the most remote vertex (let V);
2)BFS from V and find the most remote vertex (let U);
3)Create path from U and V; vertex(vertexes) in the middle is answer.

Edited by author 04.08.2015 12:56
Re: Idea O(N)
Posted by Skeef79 4 Nov 2019 15:11
It can be done easier , look here https://codeforces.com/blog/entry/17974?locale=ru