Codeforces Round 397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined)

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
765 Codeforces Round 397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) FINISHED False 10800 250379687 Feb. 14, 2017, 8:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1295 ) E Tree Folding PROGRAMMING dfs and similar dp greedy implementation trees 2200

B'Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 xe2 x80 x89= xe2 x80 x89v, a1, ..., ak, and b0 xe2 x80 x89= xe2 x80 x89v, b1, ..., bk. Additionally, vertices a1, ..., ak, b1, ..., bk must not have any neighbours in the tree other than adjacent vertices of corresponding paths. After that, one of the paths may be merged into the other, that is, the vertices b1, ..., bk can be effectively erased: Help Vanya determine if it possible to make the tree into a path via a sequence of described operations, and if the answer is positive, also determine the shortest length of such path. The first line of input contains the number of vertices n (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892 xc2 xb7105). Next n xe2 x80 x89- xe2 x80 x891 lines describe edges of the tree. Each of these lines contains two space-separated integers u and v (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89u, xe2 x80 x89v xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, u xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89v) -- indices of endpoints of the corresponding edge. It is guaranteed that the given graph is a tree. If it is impossible to obtain a path, print -1. Otherwise, print the minimum number of edges in a possible path. In the first sample case, a path of three edges is obtained after merging paths 2 xe2 x80 x89- xe2 x80 x891 xe2 x80 x89- xe2 x80 x896 and 2 xe2 x80 x89- xe2 x80 x894 xe2 x80 x89- xe2 x80 x895. It is impossible to perform any operation in the second sample case. For example, it is impossible to merge paths 1 xe2 x80 x89- xe2 x80 x893 xe2 x80 x89- xe2 x80 x894 and 1 xe2 x80 x89- xe2 x80 x895 xe2 x80 x89- xe2 x80 x896, since vertex 6 additionally has a neighbour 7 that is not present in the corresponding path. '...

Tutorials

Codeforces Round #397 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
24668829 TheHedgehog E Feb. 14, 2017, 12:09 p.m. OK Delphi TESTS 54 280 49561600 2200
24668713 Sanja E Feb. 14, 2017, 12:06 p.m. OK FPC TESTS 54 109 10956800 2200
24671542 zzhao1996 E Feb. 14, 2017, 1:41 p.m. OK GNU C TESTS 54 109 8396800 2200
24664034 Tebak_Siapa_Aku E Feb. 14, 2017, 10:17 a.m. OK GNU C TESTS 54 249 21094400 2200
24663139 Dream-Reality E Feb. 14, 2017, 10:05 a.m. OK GNU C++ TESTS 54 46 17408000 2200
25647627 xzyxzy E March 19, 2017, 1:50 p.m. OK GNU C++ TESTS 54 61 13824000 2200
24659137 CHNZYX E Feb. 14, 2017, 9:20 a.m. OK GNU C++ TESTS 54 61 17408000 2200
40982517 ReaLNero1 E July 30, 2018, 6:27 p.m. OK GNU C++ TESTS 54 62 15360000 2200
24665888 xjtt E Feb. 14, 2017, 10:44 a.m. OK GNU C++ TESTS 54 62 15564800 2200
24798272 paul.zrm E Feb. 19, 2017, 9:06 a.m. OK GNU C++ TESTS 54 62 17408000 2200
24663025 MarkF E Feb. 14, 2017, 10:04 a.m. OK GNU C++ TESTS 54 62 19046400 2200
24669182 zhouhebin E Feb. 14, 2017, 12:17 p.m. OK GNU C++ TESTS 54 77 11673600 2200
26735105 Salim_Shebli E April 28, 2017, 8:47 p.m. OK GNU C++ TESTS 54 77 13824000 2200
24666396 dwjshift E Feb. 14, 2017, 10:51 a.m. OK GNU C++ TESTS 54 77 22937600 2200
44340351 PupilFop_zz E Oct. 15, 2018, 2:50 a.m. OK GNU C++11 TESTS 54 46 16486400 2200
24661418 248926 E Feb. 14, 2017, 9:45 a.m. OK GNU C++11 TESTS 54 61 15974400 2200
24663627 666sb666 E Feb. 14, 2017, 10:12 a.m. OK GNU C++11 TESTS 54 62 9830400 2200
44345456 zhoudong E Oct. 15, 2018, 6:59 a.m. OK GNU C++11 TESTS 54 62 18432000 2200
24663843 Remilia-Scarlet E Feb. 14, 2017, 10:15 a.m. OK GNU C++11 TESTS 54 77 14643200 2200
44338229 q234rty E Oct. 15, 2018, 12:17 a.m. OK GNU C++11 TESTS 54 77 38502400 2200
44565830 liangziqi E Oct. 19, 2018, 11:30 p.m. OK GNU C++11 TESTS 54 78 13516800 2200
44348072 zhaotiensn E Oct. 15, 2018, 8:30 a.m. OK GNU C++11 TESTS 54 93 8908800 2200
25068084 0xA28 E Feb. 27, 2017, 3:11 a.m. OK GNU C++11 TESTS 54 93 12390400 2200
58420185 luogu_bot4 E Aug. 7, 2019, 7:22 a.m. OK GNU C++11 TESTS 54 93 13004800 2200
31523968 q234rty E Oct. 20, 2017, 5:18 a.m. OK GNU C++14 TESTS 54 93 40448000 2200
53484682 NiroBC E April 29, 2019, 1:47 a.m. OK GNU C++14 TESTS 54 109 7168000 2200
44422590 pufanyi E Oct. 17, 2018, 12:44 a.m. OK GNU C++14 TESTS 54 124 7884800 2200
25128362 JoelSotoMamani E March 1, 2017, 4:10 p.m. OK GNU C++14 TESTS 54 124 11366400 2200
34507257 vjudge3 E Jan. 24, 2018, 7:25 a.m. OK GNU C++14 TESTS 54 140 10035200 2200
24671321 la1la1la E Feb. 14, 2017, 1:32 p.m. OK GNU C++14 TESTS 54 140 11468800 2200
24671365 TLE E Feb. 14, 2017, 1:33 p.m. OK GNU C++14 TESTS 54 140 20787200 2200
24688393 ColdHeat E Feb. 15, 2017, 7:26 a.m. OK GNU C++14 TESTS 54 171 11776000 2200
24659376 Constantius E Feb. 14, 2017, 9:22 a.m. OK GNU C++14 TESTS 54 171 12902400 2200
24666902 Andrei1998 E Feb. 14, 2017, 10:57 a.m. OK GNU C++14 TESTS 54 171 13414400 2200
44526647 xumingyang E Oct. 19, 2018, 3:16 a.m. OK GNU C++17 TESTS 54 124 20582400 2200
56774077 devarshi09 E July 10, 2019, 1:21 a.m. OK GNU C++17 TESTS 54 171 24985600 2200
45287106 YazanRi E Nov. 4, 2018, 5:23 p.m. OK GNU C++17 TESTS 54 186 22425600 2200
48713649 Hacheylight E Jan. 22, 2019, 9:56 a.m. OK GNU C++17 TESTS 54 186 22937600 2200
48030154 Shayan.P E Jan. 6, 2019, 11:53 a.m. OK GNU C++17 TESTS 54 187 21504000 2200
52295439 Vanishment E April 4, 2019, 5:48 a.m. OK GNU C++17 TESTS 54 202 20582400 2200
60089847 vjudge1 E Sept. 5, 2019, 2:53 p.m. OK GNU C++17 TESTS 54 202 21299200 2200
54393043 Ajax E May 19, 2019, 5:44 p.m. OK GNU C++17 TESTS 54 202 22630400 2200
50284625 ILSYT E Feb. 21, 2019, 2:17 p.m. OK GNU C++17 TESTS 54 202 32870400 2200
62589340 filipeabelha E Oct. 14, 2019, 8:14 p.m. OK GNU C++17 TESTS 54 217 15052800 2200
24664019 mmaxio E Feb. 14, 2017, 10:17 a.m. OK Java 8 TESTS 54 264 28569600 2200
24656861 pashka E Feb. 14, 2017, 9:01 a.m. OK Java 8 TESTS 54 280 30515200 2200
24661426 uwi E Feb. 14, 2017, 9:45 a.m. OK Java 8 TESTS 54 280 41369600 2200
24694815 IgorKoval E Feb. 15, 2017, 12:26 p.m. OK Java 8 TESTS 54 436 112332800 2200
40386317 mariem_kandil E July 15, 2018, 6:44 p.m. OK Java 8 TESTS 54 467 23244800 2200
24693255 IgorKoval E Feb. 15, 2017, 11:19 a.m. OK Java 8 TESTS 54 530 40857600 2200
24665306 fnch E Feb. 14, 2017, 10:36 a.m. OK Java 8 TESTS 54 592 68505600 2200
24660641 ilyakor E Feb. 14, 2017, 9:36 a.m. OK Java 8 TESTS 54 638 106700800 2200
41303944 Hoda_Hisham E Aug. 7, 2018, noon OK Java 8 TESTS 54 639 45875200 2200
24676866 kenkoooo E Feb. 14, 2017, 5:15 p.m. OK Java 8 TESTS 54 655 101990400 2200
24660152 chokudai E Feb. 14, 2017, 9:30 a.m. OK MS C# TESTS 54 530 38400000 2200
24669863 mircea85 E Feb. 14, 2017, 12:36 p.m. OK MS C# TESTS 54 670 44851200 2200
24666105 fiver E Feb. 14, 2017, 10:47 a.m. OK MS C# TESTS 54 763 109260800 2200
24680286 Neverauskas E Feb. 14, 2017, 7:55 p.m. OK MS C# TESTS 54 920 65843200 2200
24680349 Neverauskas E Feb. 14, 2017, 7:58 p.m. OK MS C# TESTS 54 1091 65945600 2200
24696449 fr0st E Feb. 15, 2017, 1:21 p.m. OK MS C# TESTS 54 1310 51097600 2200
44429974 hengheng E Oct. 17, 2018, 7:08 a.m. OK MS C++ TESTS 54 155 24576000 2200
24661297 Oleg_Smirnov E Feb. 14, 2017, 9:43 a.m. OK MS C++ TESTS 54 187 14643200 2200
24664369 DEGwer E Feb. 14, 2017, 10:23 a.m. OK MS C++ TESTS 54 234 19558400 2200
24670188 AU.Bahosain E Feb. 14, 2017, 12:46 p.m. OK MS C++ TESTS 54 234 21299200 2200
24728603 miagkov E Feb. 17, 2017, 12:17 a.m. OK MS C++ TESTS 54 249 25088000 2200
24666394 superwatermelon E Feb. 14, 2017, 10:51 a.m. OK MS C++ TESTS 54 265 15769600 2200
24692829 Rafaaaaaaaaaaaam E Feb. 15, 2017, 10:59 a.m. OK MS C++ TESTS 54 312 37068800 2200
24734971 wp32pw E Feb. 17, 2017, 9:14 a.m. OK MS C++ TESTS 54 327 31129600 2200
24665535 robinyu E Feb. 14, 2017, 10:40 a.m. OK MS C++ TESTS 54 420 14540800 2200
24663509 kingofnumbers E Feb. 14, 2017, 10:10 a.m. OK MS C++ TESTS 54 529 16486400 2200
61393880 pajenegod E Sept. 28, 2019, 12:21 a.m. OK PyPy 2 TESTS 54 748 40345600 2200
24738507 Ehzyo E Feb. 17, 2017, 12:36 p.m. OK PyPy 2 TESTS 54 1996 128204800 2200
24819268 iehn E Feb. 20, 2017, 9:55 a.m. OK Python 3 TESTS 54 1840 59801600 2200
24819217 iehn E Feb. 20, 2017, 9:51 a.m. OK Python 3 TESTS 54 1871 60620800 2200
24819303 iehn E Feb. 20, 2017, 9:57 a.m. OK Python 3 TESTS 54 1950 67993600 2200
24819325 iehn E Feb. 20, 2017, 9:58 a.m. OK Python 3 TESTS 54 1981 67891200 2200
24710071 mio_h E Feb. 16, 2017, 5:30 a.m. OK Rust TESTS 54 202 93593600 2200

remove filters

Back to search problems