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'Ksyusha has a pet chinchilla, a tree on n vertices and huge scissors. A tree is a connected graph without cycles. During a boring physics lesson Ksyusha thought about how to entertain her pet. Chinchillas like to play with branches. A branch is a tree of 3 vertices. A cut is the removal of some (not yet cut) edge in the tree. Ksyusha has plenty of free time, so she can afford to make enough cuts so that the tree splits into branches. In other words, after several (possibly zero) cuts, each vertex must belong to exactly one branch. Help Ksyusha choose the edges to be cut or tell that it is impossible. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- number of testcases. The first line of each testcase contains a single integer n ( 2 <= n <= 2 cdot 10^5 ) -- the number of vertices in the tree. The next n - 1 rows of each testcase contain integers v_i and u_i ( 1 <= v_i, u_i <= n ) -- the numbers of vertices that the i -th edge connects. It is guaranteed that this set of edges forms a tree. It is also guaranteed that the sum of n over all testcases does not exceed 2 cdot 10^5 . Print the answer for each testcase. If the desired way to cut the tree does not exist, print -1 . Otherwise, print an integer k -- the number of edges to be cut. In the next line, print k different integers e_i ( 1 <= e_i < n ) -- numbers of the edges to be cut. If k = 0 , print an empty string instead. If there are several solutions, you can print any. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
206577242 |
mban259 |
G |
May 20, 2023, 12:48 a.m. |
OK |
C# 10 |
TESTS |
14 |
342 |
32870400 |
|
|
206535400 |
zoro500 |
G |
May 19, 2023, 4:32 p.m. |
OK |
C# 10 |
TESTS |
13 |
841 |
63283200 |
|
|
206536389 |
Gassa |
G |
May 19, 2023, 4:34 p.m. |
OK |
D |
TESTS |
13 |
2449 |
76185600 |
|
|
206546888 |
Coffee_zzz |
G |
May 19, 2023, 5:04 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
77 |
29900800 |
|
|
206545742 |
Zero_Skillz_999 |
G |
May 19, 2023, 4:58 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
93 |
5120000 |
|
|
206547713 |
scumbag_ |
G |
May 19, 2023, 5:10 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
109 |
7270400 |
|
|
206533982 |
icyM3tra |
G |
May 19, 2023, 4:28 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
109 |
10444800 |
|
|
206573622 |
Just_a_dude |
G |
May 19, 2023, 10:37 p.m. |
OK |
GNU C++14 |
TESTS |
14 |
124 |
9932800 |
|
|
206536210 |
cqbzzhy |
G |
May 19, 2023, 4:33 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
139 |
8704000 |
|
|
206563403 |
jnarutoj |
G |
May 19, 2023, 7:17 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
139 |
9113600 |
|
|
206537171 |
robertofirmino09 |
G |
May 19, 2023, 4:36 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
140 |
7372800 |
|
|
206537879 |
Cu_OH_2 |
G |
May 19, 2023, 4:37 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
140 |
9932800 |
|
|
206573950 |
zltzlt |
G |
May 19, 2023, 10:48 p.m. |
OK |
GNU C++14 |
TESTS |
14 |
140 |
10137600 |
|
|
206546122 |
wronganswerr |
G |
May 19, 2023, 5 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
109 |
7475200 |
|
|
206544822 |
2soon |
G |
May 19, 2023, 4:53 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
109 |
12083200 |
|
|
206537442 |
LY.Leocsse |
G |
May 19, 2023, 4:36 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
139 |
9113600 |
|
|
206555992 |
MouayadL7 |
G |
May 19, 2023, 5:53 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
139 |
9932800 |
|
|
206538782 |
Amit7777 |
G |
May 19, 2023, 4:39 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
139 |
9932800 |
|
|
206547238 |
Shuishui_0921 |
G |
May 19, 2023, 5:07 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
139 |
12288000 |
|
|
206565170 |
Mkswll |
G |
May 19, 2023, 7:41 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
140 |
8499200 |
|
|
206575324 |
George_Rubio |
G |
May 19, 2023, 11:36 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
140 |
9113600 |
|
|
206573327 |
nibujiu |
G |
May 19, 2023, 10:27 p.m. |
OK |
GNU C++17 |
TESTS |
14 |
140 |
9113600 |
|
|
206550514 |
AlexRex0 |
G |
May 19, 2023, 5:18 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
140 |
9113600 |
|
|
206570075 |
Mostafa_Moharram |
G |
May 19, 2023, 9:02 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
124 |
12288000 |
|
|
206574066 |
timmyfeng |
G |
May 19, 2023, 10:52 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
139 |
13107200 |
|
|
206568541 |
chappy1 |
G |
May 19, 2023, 8:32 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
140 |
13107200 |
|
|
206560128 |
Krzychuo |
G |
May 19, 2023, 6:36 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
140 |
13107200 |
|
|
206577075 |
Hytidel |
G |
May 20, 2023, 12:43 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
155 |
13107200 |
|
|
206539177 |
verynewabie |
G |
May 19, 2023, 4:40 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
155 |
14131200 |
|
|
206576497 |
Rania |
G |
May 20, 2023, 12:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
155 |
15462400 |
|
|
206538951 |
haengsyo |
G |
May 19, 2023, 4:40 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
171 |
13312000 |
|
|
206568878 |
Ahmad-Magdy |
G |
May 19, 2023, 8:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
186 |
21504000 |
|
|
206571177 |
enslaved |
G |
May 19, 2023, 9:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
14 |
202 |
13414400 |
|
|
206542880 |
sukabulie |
G |
May 19, 2023, 4:48 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
78 |
7475200 |
|
|
206538545 |
HUCSr |
G |
May 19, 2023, 4:39 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
78 |
21401600 |
|
|
206541313 |
stdforces |
G |
May 19, 2023, 4:45 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
93 |
7475200 |
|
|
206550111 |
kofu |
G |
May 19, 2023, 5:15 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
93 |
9625600 |
|
|
206577754 |
cmk666 |
G |
May 20, 2023, 1:03 a.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
93 |
12390400 |
|
|
206560095 |
sword060 |
G |
May 19, 2023, 6:35 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
108 |
12288000 |
|
|
206553091 |
A_Very_Serious_Man |
G |
May 19, 2023, 5:25 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
108 |
12288000 |
|
|
206547684 |
MiinaMagdy |
G |
May 19, 2023, 5:09 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
109 |
12288000 |
|
|
206536223 |
McPqndq |
G |
May 19, 2023, 4:33 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
109 |
12288000 |
|
|
206574756 |
NO__OB |
G |
May 19, 2023, 11:15 p.m. |
OK |
GNU C++20 (64) |
TESTS |
14 |
124 |
12185600 |
|
|
206566557 |
kribri |
G |
May 19, 2023, 8:01 p.m. |
OK |
Java 11 |
TESTS |
14 |
904 |
35225600 |
|
|
206574363 |
biu_biu_biu |
G |
May 19, 2023, 11:02 p.m. |
OK |
Java 11 |
TESTS |
14 |
1278 |
33689600 |
|
|
206533963 |
Vrutik_2809 |
G |
May 19, 2023, 4:28 p.m. |
OK |
Java 17 |
TESTS |
13 |
483 |
34406400 |
|
|
206552560 |
frey4 |
G |
May 19, 2023, 5:21 p.m. |
OK |
Java 17 |
TESTS |
13 |
935 |
68096000 |
|
|
206547614 |
LeetCodeforces_Null |
G |
May 19, 2023, 5:09 p.m. |
OK |
Java 17 |
TESTS |
13 |
1497 |
153702400 |
|
|
206542745 |
Virendra115 |
G |
May 19, 2023, 4:48 p.m. |
OK |
Java 8 |
TESTS |
13 |
919 |
54784000 |
|
|
206534559 |
s_zx |
G |
May 19, 2023, 4:30 p.m. |
OK |
Java 8 |
TESTS |
13 |
1559 |
39731200 |
|
|
206536424 |
DottedCalculator |
G |
May 19, 2023, 4:34 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
576 |
52531200 |
|
|
206570486 |
gardengnome |
G |
May 19, 2023, 9:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
623 |
55193600 |
|
|
206574326 |
mkawa2 |
G |
May 19, 2023, 11 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
717 |
101580800 |
|
|
206572702 |
Khaild_Salman |
G |
May 19, 2023, 10:08 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
810 |
96256000 |
|
|
206536201 |
DottedCalculator |
G |
May 19, 2023, 4:33 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
1700 |
55091200 |
|
|
206535678 |
shash4321 |
G |
May 19, 2023, 4:32 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
1762 |
145305600 |
|
|
206546411 |
mikeac |
G |
May 19, 2023, 5:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
2136 |
61952000 |
|
|
206535696 |
josewxy |
G |
May 19, 2023, 4:32 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
2136 |
61952000 |
|
|
206540198 |
yupooh |
G |
May 19, 2023, 4:43 p.m. |
OK |
Python 3 |
TESTS |
13 |
889 |
77209600 |
|
|
206573018 |
magnus.hegdahl |
G |
May 19, 2023, 10:18 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
31 |
10649600 |
|
|
206550223 |
0npata |
G |
May 19, 2023, 5:15 p.m. |
OK |
Rust 2021 |
TESTS |
13 |
124 |
24064000 |
|
|
206546643 |
YummyPie |
G |
May 19, 2023, 5:03 p.m. |
OK |
Rust 2021 |
TESTS |
13 |
140 |
25088000 |
|
|
206539578 |
0npata |
G |
May 19, 2023, 4:41 p.m. |
OK |
Rust 2021 |
TESTS |
13 |
171 |
39628800 |
|
|
206546903 |
haihamabossu |
G |
May 19, 2023, 5:04 p.m. |
OK |
Rust 2021 |
TESTS |
13 |
202 |
45772800 |
|
|
remove filters
Back to search problems