Codeforces Round 670 (Div. 2)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1406 Codeforces Round 670 (Div. 2) FINISHED False 7200 137261663 Sept. 12, 2020, 1:45 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 10467 ) C Link Cut Centroids PROGRAMMING constructive algorithms dfs and similar graphs trees

B"Fishing Prince loves trees, and he especially loves trees with only one centroid. The tree is a connected graph without cycles. A vertex is a centroid of a tree only when you cut this vertex (remove it and remove all edges from this vertex), the size of the largest connected component of the remaining graph is the smallest possible. For example, the centroid of the following tree is 2 , because when you cut it, the size of the largest connected component of the remaining graph is 2 and it can't be smaller. However, in some trees, there might be more than one centroid, for example: Both vertex 1 and vertex 2 are centroids because the size of the largest connected component is 3 after cutting each of them. Now Fishing Prince has a tree. He should cut one edge of the tree (it means to remove the edge). After that, he should add one edge. The resulting graph after these two operations should be a tree. He can add the edge that he cut. He wants the centroid of the resulting tree to be unique. Help him and find any possible way to make the operations. It can be proved, that at least one such way always exists. The input consists of multiple test cases. The first line contains an integer t ( 1 <= q t <= q 10^4 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains an integer n ( 3 <= q n <= q 10^5 ) -- the number of vertices. Each of the next n-1 lines contains two integers x, y ( 1 <= q x,y <= q n ). It means, that there exists an edge connecting vertices x and y . It's guaranteed that the given graph is a tree. It's guaranteed that the sum of n for all test cases does not exceed 10^5 . For each test case, print two lines. In the first line print two integers x_1, y_1 ( 1 <= q x_1, y_1 <= q n ), which means you cut the edge between vertices x_1 and y_1 . There should exist edge connecting vertices $$"...

Tutorials

Codeforces Round #670 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
92640655 YOK C Sept. 12, 2020, 3:43 p.m. OK GNU C11 TESTS 16 109 5222400
92644462 pengin_2000 C Sept. 12, 2020, 4:16 p.m. OK GNU C11 TESTS 16 124 5632000
92670087 smsylby C Sept. 12, 2020, 11:07 p.m. OK GNU C++11 TESTS 16 31 7475200
92672716 2016wudi C Sept. 13, 2020, 1:11 a.m. OK GNU C++11 TESTS 16 31 8192000
92646791 myx12345 C Sept. 12, 2020, 4:29 p.m. OK GNU C++11 TESTS 16 31 23244800
92674654 formkiller C Sept. 13, 2020, 2:13 a.m. OK GNU C++11 TESTS 16 31 25292800
92643315 vinhntndu C Sept. 12, 2020, 4:11 p.m. OK GNU C++11 TESTS 16 31 32870400
92672466 aa___ C Sept. 13, 2020, 1:01 a.m. OK GNU C++11 TESTS 16 46 5836800
92674263 luogu_bot1 C Sept. 13, 2020, 2 a.m. OK GNU C++11 TESTS 16 46 6041600
92674443 EricQian C Sept. 13, 2020, 2:07 a.m. OK GNU C++11 TESTS 16 46 6246400
92643182 cy90 C Sept. 12, 2020, 4:10 p.m. OK GNU C++11 TESTS 16 46 7168000
92670193 4790iop C Sept. 12, 2020, 11:12 p.m. OK GNU C++11 TESTS 16 46 7577600
92653631 ritesh1340 C Sept. 12, 2020, 5:34 p.m. OK GNU C++14 TESTS 16 62 7782400
92674932 liujia123456 C Sept. 13, 2020, 2:21 a.m. OK GNU C++14 TESTS 16 62 28876800
92671336 MorningDew C Sept. 13, 2020, 12:13 a.m. OK GNU C++14 TESTS 16 62 33280000
92679241 Madhunter C Sept. 13, 2020, 4:12 a.m. OK GNU C++14 TESTS 16 77 5734400
92675553 Mackerel_Pike C Sept. 13, 2020, 2:38 a.m. OK GNU C++14 TESTS 16 77 6144000
92682457 hdilantha C Sept. 13, 2020, 5:18 a.m. OK GNU C++14 TESTS 16 77 7782400
92639790 brut_force C Sept. 12, 2020, 3:41 p.m. OK GNU C++14 TESTS 16 77 8089600
92652848 dotoleeoak C Sept. 12, 2020, 5:25 p.m. OK GNU C++14 TESTS 16 77 8192000
92655285 harsh639 C Sept. 12, 2020, 5:53 p.m. OK GNU C++14 TESTS 16 77 8192000
92655206 rocks03 C Sept. 12, 2020, 5:52 p.m. OK GNU C++14 TESTS 16 77 8192000
92673424 t3018210153 C Sept. 13, 2020, 1:33 a.m. OK GNU C++17 TESTS 16 62 7168000
92685036 terrcota C Sept. 13, 2020, 5:57 a.m. OK GNU C++17 TESTS 16 62 7987200
92668182 IsaacMoris C Sept. 12, 2020, 9:50 p.m. OK GNU C++17 TESTS 16 62 9728000
92660603 bsbs C Sept. 12, 2020, 7:05 p.m. OK GNU C++17 TESTS 16 62 11468800
92678410 jiangly C Sept. 13, 2020, 3:51 a.m. OK GNU C++17 TESTS 16 62 11776000
92674598 _andyli C Sept. 13, 2020, 2:12 a.m. OK GNU C++17 TESTS 16 62 12697600
92683550 N_g_M C Sept. 13, 2020, 5:34 a.m. OK GNU C++17 TESTS 16 62 14233600
92644873 Superdanby C Sept. 12, 2020, 4:18 p.m. OK GNU C++17 TESTS 16 77 3788800
92677124 yuto1115 C Sept. 13, 2020, 3:18 a.m. OK GNU C++17 TESTS 16 77 5120000
92675558 s1012480564 C Sept. 13, 2020, 2:38 a.m. OK GNU C++17 TESTS 16 77 5222400
92681328 LayCurse C Sept. 13, 2020, 4:58 a.m. OK GNU C++17 (64) TESTS 16 46 100659200
92668249 FadingStar C Sept. 12, 2020, 9:52 p.m. OK GNU C++17 (64) TESTS 16 62 14028800
92655167 AccioAC C Sept. 12, 2020, 5:52 p.m. OK GNU C++17 (64) TESTS 16 62 16793600
92649799 quadraticreciprocity C Sept. 12, 2020, 4:53 p.m. OK GNU C++17 (64) TESTS 16 62 17203200
92679616 john__wick C Sept. 13, 2020, 4:22 a.m. OK GNU C++17 (64) TESTS 16 62 17203200
92666306 David_Garcia C Sept. 12, 2020, 8:56 p.m. OK GNU C++17 (64) TESTS 16 62 19456000
92676402 Iron_man_3000love C Sept. 13, 2020, 2:59 a.m. OK GNU C++17 (64) TESTS 16 62 19660800
92650579 axat0081 C Sept. 12, 2020, 5:01 p.m. OK GNU C++17 (64) TESTS 16 62 22220800
92645100 Kuroni C Sept. 12, 2020, 4:19 p.m. OK GNU C++17 (64) TESTS 16 77 12390400
92668218 Clu3l3ss C Sept. 12, 2020, 9:51 p.m. OK GNU C++17 (64) TESTS 16 77 14028800
92648450 Rahul C Sept. 12, 2020, 4:41 p.m. OK Go TESTS 16 77 26214400
92660149 pohzipohzi C Sept. 12, 2020, 6:59 p.m. OK Go TESTS 16 109 109363200
92658256 pohzipohzi C Sept. 12, 2020, 6:31 p.m. OK Go TESTS 16 233 128409600
92651139 Hasker C Sept. 12, 2020, 5:06 p.m. OK Haskell TESTS 16 202 31641600
92682708 sf14t C Sept. 13, 2020, 5:21 a.m. OK Java 11 TESTS 16 280 28569600
92647080 saikaushik C Sept. 12, 2020, 4:31 p.m. OK Java 11 TESTS 16 296 28876800
92650745 cribabby C Sept. 12, 2020, 5:02 p.m. OK Java 11 TESTS 16 296 41574400
92651634 nalin_1000101 C Sept. 12, 2020, 5:12 p.m. OK Java 11 TESTS 16 311 27955200
92653939 akman10 C Sept. 12, 2020, 5:38 p.m. OK Java 11 TESTS 16 311 56934400
92653344 akman10 C Sept. 12, 2020, 5:31 p.m. OK Java 11 TESTS 16 343 56934400
92654777 Apass.Jack C Sept. 12, 2020, 5:48 p.m. OK Java 11 TESTS 16 358 17612800
92652366 shrey_shreyansh C Sept. 12, 2020, 5:20 p.m. OK Java 11 TESTS 16 374 33792000
92648546 SevenDeadlySins C Sept. 12, 2020, 4:42 p.m. OK Java 11 TESTS 16 389 4096000
92645917 blackBird C Sept. 12, 2020, 4:23 p.m. OK Java 11 TESTS 16 389 25292800
92655488 revanthreddy85 C Sept. 12, 2020, 5:55 p.m. OK Java 8 TESTS 16 218 59084800
92684849 tarun_sm C Sept. 13, 2020, 5:54 a.m. OK Java 8 TESTS 16 233 53862400
92648648 pupil_forever C Sept. 12, 2020, 4:43 p.m. OK Java 8 TESTS 16 248 61337600
92669927 ShesMyNerd C Sept. 12, 2020, 10:59 p.m. OK Java 8 TESTS 16 249 48230400
92674254 cf_cf C Sept. 13, 2020, 2 a.m. OK Java 8 TESTS 16 249 54988800
92648716 poojakandoi06 C Sept. 12, 2020, 4:43 p.m. OK Java 8 TESTS 16 264 25804800
92642925 prd_xxx C Sept. 12, 2020, 4:10 p.m. OK Java 8 TESTS 16 264 41574400
92645522 YahiaSherif C Sept. 12, 2020, 4:21 p.m. OK Java 8 TESTS 16 265 24268800
92643578 booooooo C Sept. 12, 2020, 4:12 p.m. OK Java 8 TESTS 16 280 25497600
92648769 poketred12 C Sept. 12, 2020, 4:44 p.m. OK Java 8 TESTS 16 280 26624000
92682875 Spheniscine C Sept. 13, 2020, 5:24 a.m. OK Kotlin TESTS 16 218 7680000
92682666 Spheniscine C Sept. 13, 2020, 5:20 a.m. OK Kotlin TESTS 16 218 7680000
92682285 Spheniscine C Sept. 13, 2020, 5:15 a.m. OK Kotlin TESTS 16 218 7680000
92643727 fancy_lettuce C Sept. 12, 2020, 4:13 p.m. OK Mono C# TESTS 16 155 142336000
92649418 fancy_lettuce C Sept. 12, 2020, 4:50 p.m. OK Mono C# TESTS 16 155 276787200
92647111 terry_u16 C Sept. 12, 2020, 4:31 p.m. OK Mono C# TESTS 16 218 151552000
92639414 eSeF_ C Sept. 12, 2020, 3:41 p.m. OK Mono C# TESTS 16 296 18636800
92683857 azukun C Sept. 13, 2020, 5:39 a.m. OK Mono C# TESTS 16 467 147353600
92643613 Yupiteru C Sept. 12, 2020, 4:12 p.m. OK Mono C# TESTS 16 639 50688000
92665550 exode4 C Sept. 12, 2020, 8:36 p.m. OK MS C++ 2017 TESTS 16 108 6041600
92639388 dkyun C Sept. 12, 2020, 3:41 p.m. OK MS C++ 2017 TESTS 16 109 6041600
92641446 dundae C Sept. 12, 2020, 3:44 p.m. OK MS C++ 2017 TESTS 16 124 5324800
92672452 0Mordecai0 C Sept. 13, 2020, 1 a.m. OK MS C++ 2017 TESTS 16 187 7577600
92674189 little_lion C Sept. 13, 2020, 1:57 a.m. OK MS C++ 2017 TESTS 16 217 6041600
92655776 Miris C Sept. 12, 2020, 5:59 p.m. OK MS C++ 2017 TESTS 16 249 5427200
92654295 caandmn C Sept. 12, 2020, 5:42 p.m. OK MS C++ 2017 TESTS 16 280 6451200
92645415 YamagenSakam C Sept. 12, 2020, 4:21 p.m. OK MS C++ 2017 TESTS 16 311 33075200
92639879 charmander3333 C Sept. 12, 2020, 3:42 p.m. OK MS C++ 2017 TESTS 16 608 6451200
92669473 crystaalroo C Sept. 12, 2020, 10:39 p.m. OK PyPy 3 TESTS 16 327 18329600
92666513 marroncastle C Sept. 12, 2020, 9:01 p.m. OK PyPy 3 TESTS 16 342 13209600
92666168 kclee2172 C Sept. 12, 2020, 8:52 p.m. OK PyPy 3 TESTS 16 374 12902400
92665287 manish.17 C Sept. 12, 2020, 8:31 p.m. OK PyPy 3 TESTS 16 389 24268800
92639626 mlihua09 C Sept. 12, 2020, 3:41 p.m. OK PyPy 3 TESTS 16 405 11264000
92644382 gintoki_s C Sept. 12, 2020, 4:16 p.m. OK PyPy 3 TESTS 16 405 18124800
92641359 slijk C Sept. 12, 2020, 3:44 p.m. OK PyPy 3 TESTS 16 420 26828800
92647766 wishcode C Sept. 12, 2020, 4:36 p.m. OK PyPy 3 TESTS 16 451 16691200
92675610 manikjain4 C Sept. 13, 2020, 2:39 a.m. OK PyPy 3 TESTS 16 451 23040000
92669103 zapdospops C Sept. 12, 2020, 10:24 p.m. OK PyPy 3 TESTS 16 483 17100800
92667241 dg114 C Sept. 12, 2020, 9:22 p.m. OK Python 2 TESTS 16 530 15462400
92654989 marroncastle C Sept. 12, 2020, 5:50 p.m. OK Python 3 TESTS 16 498 12390400
92644501 WitchOfTruth C Sept. 12, 2020, 4:16 p.m. OK Python 3 TESTS 16 498 187904000
92666532 marroncastle C Sept. 12, 2020, 9:02 p.m. OK Python 3 TESTS 16 514 13107200
92648523 coder_sounak C Sept. 12, 2020, 4:41 p.m. OK Python 3 TESTS 16 670 162816000
92655086 sh1194 C Sept. 12, 2020, 5:51 p.m. OK Python 3 TESTS 16 685 15872000
92651388 Earagav C Sept. 12, 2020, 5:09 p.m. OK Python 3 TESTS 16 686 194355200
92649857 jimm89 C Sept. 12, 2020, 4:54 p.m. OK Python 3 TESTS 16 701 65536000
92680316 chinmaym749 C Sept. 13, 2020, 4:38 a.m. OK Python 3 TESTS 16 748 24678400
92645524 siddhantgarg11 C Sept. 12, 2020, 4:21 p.m. OK Python 3 TESTS 16 764 192307200
92681927 akks800 C Sept. 13, 2020, 5:08 a.m. OK Rust TESTS 16 93 7475200
92674577 bqn C Sept. 13, 2020, 2:11 a.m. OK Rust TESTS 16 249 11673600

remove filters

Back to search problems