Justice League Assemble
All submissions for this problem are available.
The Justice League's friends and family have been kidnapped by Lex Luthor. To save them, the League are presented with portals that will teleport them into Darkseid's war planet, Apokolips. There are n Leaguers and n different teleport positions. Each teleporter can be used exactly once. The teleport positions are connected by hallways of length 1 km. To walk 1 km, a Leaguer takes one unit of time. Batman believes that the team should gather under one of the team's leaders, Superman or himself as soon as possible. To that end, which positions should the leaders teleport to, so that the teams can gather under one of their leaders as quickly as possible?
The first line has an integers, the number of portals, n.
- The next (n-1) lines contain 2 integers, x and y denoting that the portals numbered x and y are connected by a hallway.
For each test case, print the minimum time such that the team can gather under their leaders.
- n <= 1e5
- Sum of n over all test cases <= 1e5 + 1000
Input: 1 2 1 2 Output: 0
Example case 1 : There are only 2 positions, which the leaders can occupy. Since they function alone, the time taken is 0 units.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions