Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"You have given tree consist of n vertices. Select a vertex as root vertex that satisfies the condition below. Determine and find if there is such root vertex in the tree. If there are multiple answers, find any of them. The first line contains a single integer n ( 1 <= n <= 10^{5} ) -- the number of vertices. Each of the next n-1 lines contains two integers v_{i} and u_{i} ( 1 <= v_{i} lt u_{i} <= n ) -- it means there is an edge exist between v_{i} and u_{i} . It is guaranteed that the graph forms tree. If there is such root vertex exists, print any of them. Otherwise, print -1 . This is the picture for the first example. 1 , 5 , 7 also can be a valid answer. This is the picture for the second example. You can see that it's impossible to find such root vertex. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
55499443 |
rainboy |
D |
June 12, 2019, 2:18 p.m. |
OK |
GNU C11 |
TESTS |
44 |
62 |
4505600 |
|
2500 |
55474702 |
rainboy |
D |
June 11, 2019, 9:45 p.m. |
OK |
GNU C11 |
TESTS |
44 |
77 |
10137600 |
|
2500 |
55956489 |
The_Crossing |
D |
June 23, 2019, 7:19 a.m. |
OK |
GNU C++11 |
TESTS |
45 |
46 |
5324800 |
|
2500 |
55576206 |
liqing |
D |
June 15, 2019, 1:17 a.m. |
OK |
GNU C++11 |
TESTS |
45 |
46 |
5939200 |
|
2500 |
55663932 |
maxtir |
D |
June 17, 2019, 1:14 a.m. |
OK |
GNU C++11 |
TESTS |
45 |
46 |
9420800 |
|
2500 |
63366849 |
guyan |
D |
Oct. 25, 2019, 7:50 a.m. |
OK |
GNU C++11 |
TESTS |
46 |
46 |
10240000 |
|
2500 |
55478614 |
star_magic_young |
D |
June 12, 2019, 3:01 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
46 |
22323200 |
|
2500 |
55528624 |
__23333 |
D |
June 13, 2019, 12:26 p.m. |
OK |
GNU C++11 |
TESTS |
45 |
46 |
23654400 |
|
2500 |
55528661 |
__23333 |
D |
June 13, 2019, 12:26 p.m. |
OK |
GNU C++11 |
TESTS |
45 |
46 |
23654400 |
|
2500 |
55610509 |
ReaLNero1 |
D |
June 16, 2019, 5:22 a.m. |
OK |
GNU C++11 |
TESTS |
45 |
46 |
23654400 |
|
2500 |
55478752 |
star_magic_young |
D |
June 12, 2019, 3:06 a.m. |
OK |
GNU C++11 |
TESTS |
44 |
61 |
22323200 |
|
2500 |
59621799 |
ciao_sora |
D |
Aug. 28, 2019, 2:27 p.m. |
OK |
GNU C++11 |
TESTS |
46 |
62 |
3891200 |
|
2500 |
56308641 |
m4h |
D |
June 30, 2019, 1:29 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
78 |
5939200 |
|
2500 |
55550221 |
Tommyr7 |
D |
June 14, 2019, 6:32 a.m. |
OK |
GNU C++14 |
TESTS |
45 |
78 |
13619200 |
|
2500 |
55478860 |
Kevin_Zhang-TW |
D |
June 12, 2019, 3:14 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
92 |
10137600 |
|
2500 |
55544637 |
Narh |
D |
June 14, 2019, 12:19 a.m. |
OK |
GNU C++14 |
TESTS |
45 |
93 |
3993600 |
|
2500 |
55546549 |
hongjun-7 |
D |
June 14, 2019, 3:24 a.m. |
OK |
GNU C++14 |
TESTS |
45 |
93 |
4710400 |
|
2500 |
55456620 |
Geothermal |
D |
June 11, 2019, 2:31 p.m. |
OK |
GNU C++14 |
TESTS |
44 |
93 |
5120000 |
|
2500 |
56950260 |
wh_ZH |
D |
July 13, 2019, 1:48 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
93 |
5632000 |
|
2500 |
55482112 |
jyhuang |
D |
June 12, 2019, 5:52 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
93 |
5939200 |
|
2500 |
55482144 |
jyhuang |
D |
June 12, 2019, 5:54 a.m. |
OK |
GNU C++14 |
TESTS |
44 |
93 |
5939200 |
|
2500 |
55565157 |
DeadPillow |
D |
June 14, 2019, 3 p.m. |
OK |
GNU C++14 |
TESTS |
45 |
93 |
7065600 |
|
2500 |
56007457 |
mohamedeltair |
D |
June 24, 2019, 4:19 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
77 |
6860800 |
|
2500 |
55489695 |
YoungK |
D |
June 12, 2019, 9:34 a.m. |
OK |
GNU C++17 |
TESTS |
44 |
78 |
5222400 |
|
2500 |
55822206 |
mohamedeltair |
D |
June 20, 2019, 9:07 a.m. |
OK |
GNU C++17 |
TESTS |
45 |
78 |
6860800 |
|
2500 |
55986962 |
4c5948 |
D |
June 24, 2019, 4:43 a.m. |
OK |
GNU C++17 |
TESTS |
45 |
78 |
8396800 |
|
2500 |
55482188 |
hyfzbtrs |
D |
June 12, 2019, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
44 |
78 |
8806400 |
|
2500 |
55498830 |
ILLLZKQF |
D |
June 12, 2019, 1:59 p.m. |
OK |
GNU C++17 |
TESTS |
44 |
78 |
8908800 |
|
2500 |
66431248 |
vjudge4 |
D |
Dec. 7, 2019, 3:04 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
78 |
9216000 |
|
2500 |
55562018 |
Edwivv |
D |
June 14, 2019, 1:12 p.m. |
OK |
GNU C++17 |
TESTS |
45 |
78 |
9420800 |
|
2500 |
55567847 |
ArshiaDadras |
D |
June 14, 2019, 4:38 p.m. |
OK |
GNU C++17 |
TESTS |
45 |
78 |
10547200 |
|
2500 |
55596992 |
90n |
D |
June 15, 2019, 3:37 p.m. |
OK |
GNU C++17 |
TESTS |
45 |
78 |
13824000 |
|
2500 |
55457796 |
uwi |
D |
June 11, 2019, 2:39 p.m. |
OK |
Java 8 |
TESTS |
44 |
217 |
13926400 |
|
2500 |
55499444 |
Dukkha |
D |
June 12, 2019, 2:18 p.m. |
OK |
Java 8 |
TESTS |
44 |
327 |
17612800 |
|
2500 |
55463089 |
Sharon |
D |
June 11, 2019, 3:49 p.m. |
OK |
Java 8 |
TESTS |
44 |
358 |
29184000 |
|
2500 |
57611141 |
Oopsimbad |
D |
July 23, 2019, 8:56 p.m. |
OK |
Java 8 |
TESTS |
46 |
389 |
44953600 |
|
2500 |
55463289 |
NighTurs |
D |
June 11, 2019, 3:50 p.m. |
OK |
Java 8 |
TESTS |
44 |
404 |
14028800 |
|
2500 |
55474701 |
Dukkha |
D |
June 11, 2019, 9:45 p.m. |
OK |
Java 8 |
TESTS |
44 |
405 |
57139200 |
|
2500 |
55511540 |
SpargelTarzan |
D |
June 12, 2019, 11:34 p.m. |
OK |
Java 8 |
TESTS |
45 |
451 |
15667200 |
|
2500 |
55546879 |
tapopadma |
D |
June 14, 2019, 3:48 a.m. |
OK |
Java 8 |
TESTS |
45 |
468 |
30924800 |
|
2500 |
55562154 |
lpm |
D |
June 14, 2019, 1:16 p.m. |
OK |
Java 8 |
TESTS |
45 |
482 |
32768000 |
|
2500 |
55480452 |
SpargelTarzan |
D |
June 12, 2019, 4:40 a.m. |
OK |
Java 8 |
TESTS |
44 |
498 |
16793600 |
|
2500 |
55847962 |
SpinDOS |
D |
June 21, 2019, 12:11 a.m. |
OK |
Mono C# |
TESTS |
45 |
327 |
21708800 |
|
2500 |
55807600 |
SpinDOS |
D |
June 20, 2019, 12:36 a.m. |
OK |
Mono C# |
TESTS |
45 |
358 |
22118400 |
|
2500 |
55807643 |
SpinDOS |
D |
June 20, 2019, 12:38 a.m. |
OK |
Mono C# |
TESTS |
45 |
358 |
22220800 |
|
2500 |
55807420 |
SpinDOS |
D |
June 20, 2019, 12:20 a.m. |
OK |
Mono C# |
TESTS |
45 |
358 |
22220800 |
|
2500 |
55807576 |
SpinDOS |
D |
June 20, 2019, 12:34 a.m. |
OK |
Mono C# |
TESTS |
45 |
358 |
22220800 |
|
2500 |
56555869 |
S.K |
D |
July 5, 2019, 12:19 p.m. |
OK |
MS C++ |
TESTS |
46 |
93 |
7372800 |
|
2500 |
60636634 |
vjudge3 |
D |
Sept. 15, 2019, 2:06 p.m. |
OK |
MS C++ |
TESTS |
46 |
93 |
7884800 |
|
2500 |
58173808 |
vjudge2 |
D |
Aug. 2, 2019, 12:20 p.m. |
OK |
MS C++ |
TESTS |
46 |
93 |
10854400 |
|
2500 |
60636569 |
vjudge1 |
D |
Sept. 15, 2019, 2:05 p.m. |
OK |
MS C++ |
TESTS |
46 |
108 |
7680000 |
|
2500 |
60635654 |
vjudge4 |
D |
Sept. 15, 2019, 1:43 p.m. |
OK |
MS C++ |
TESTS |
46 |
140 |
8089600 |
|
2500 |
56481545 |
vjudge3 |
D |
July 3, 2019, 4:20 p.m. |
OK |
MS C++ |
TESTS |
46 |
171 |
4812800 |
|
2500 |
55737703 |
Mao_Z |
D |
June 19, 2019, 5:32 a.m. |
OK |
MS C++ |
TESTS |
45 |
280 |
12492800 |
|
2500 |
56429781 |
kingee |
D |
July 2, 2019, 11:30 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
124 |
7270400 |
|
2500 |
60636486 |
zhangwen123 |
D |
Sept. 15, 2019, 2:03 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
124 |
7987200 |
|
2500 |
60529098 |
zhangwen123 |
D |
Sept. 14, 2019, 11:36 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
124 |
8806400 |
|
2500 |
60635591 |
zhangwen123 |
D |
Sept. 15, 2019, 1:41 p.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
155 |
7577600 |
|
2500 |
55463619 |
camille |
D |
June 11, 2019, 3:54 p.m. |
OK |
MS C++ 2017 |
TESTS |
44 |
186 |
11980800 |
|
2500 |
55460676 |
serg3000 |
D |
June 11, 2019, 2:58 p.m. |
OK |
MS C++ 2017 |
TESTS |
44 |
249 |
8806400 |
|
2500 |
55972433 |
ielenik |
D |
June 23, 2019, 3:33 p.m. |
OK |
MS C++ 2017 |
TESTS |
45 |
249 |
9932800 |
|
2500 |
55461102 |
re_eVVorld |
D |
June 11, 2019, 3 p.m. |
OK |
MS C++ 2017 |
TESTS |
44 |
311 |
10240000 |
|
2500 |
58426737 |
sjship |
D |
Aug. 7, 2019, 10:01 a.m. |
OK |
MS C++ 2017 |
TESTS |
46 |
452 |
25497600 |
|
2500 |
55460698 |
camille |
D |
June 11, 2019, 2:58 p.m. |
OK |
MS C++ 2017 |
TESTS |
44 |
889 |
12390400 |
|
2500 |
55468185 |
erb666 |
D |
June 11, 2019, 5:22 p.m. |
OK |
Node.js |
TESTS |
44 |
670 |
44339200 |
|
2500 |
55481619 |
nik-in-au |
D |
June 12, 2019, 5:35 a.m. |
OK |
PyPy 3 |
TESTS |
44 |
545 |
23449600 |
|
2500 |
55500597 |
pineriver |
D |
June 12, 2019, 2:52 p.m. |
OK |
PyPy 3 |
TESTS |
44 |
608 |
30822400 |
|
2500 |
56369768 |
Pokeylope |
D |
July 1, 2019, 2:42 a.m. |
OK |
PyPy 3 |
TESTS |
46 |
654 |
18124800 |
|
2500 |
57811772 |
Helli.code |
D |
July 26, 2019, 5:42 p.m. |
OK |
Python 2 |
TESTS |
46 |
998 |
14336000 |
|
2500 |
55471837 |
Skybytskyi.Nikita |
D |
June 11, 2019, 7:18 p.m. |
OK |
Python 3 |
TESTS |
44 |
857 |
14028800 |
|
2500 |
55502792 |
tiantian5 |
D |
June 12, 2019, 3:59 p.m. |
OK |
Python 3 |
TESTS |
44 |
998 |
13516800 |
|
2500 |
55530313 |
andreyrmg |
D |
June 13, 2019, 1:15 p.m. |
OK |
Rust |
TESTS |
45 |
93 |
13516800 |
|
2500 |
55530025 |
andreyrmg |
D |
June 13, 2019, 1:06 p.m. |
OK |
Rust |
TESTS |
45 |
93 |
13516800 |
|
2500 |
55459031 |
rustaurance |
D |
June 11, 2019, 2:47 p.m. |
OK |
Rust |
TESTS |
44 |
124 |
8089600 |
|
2500 |
remove filters
Back to search problems