Codeforces Round 398 (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
767 Codeforces Round 398 (Div. 2) FINISHED False 7200 288996923 Feb. 18, 2017, 9:05 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 4630 ) C Garland PROGRAMMING dfs and similar graphs greedy trees 2000

Once at New Year Dima had a dream in which he was presented a fairy garland. A garland is a set of lamps, some pairs of which are connected by wires. Dima remembered that each two lamps in the garland were connected directly or indirectly via some wires. Furthermore, the number of wires was exactly one less than the number of lamps. There was something unusual about the garland. Each lamp had its own brightness which depended on the temperature of the lamp. Temperatures could be positive, negative or zero. Dima has two friends, so he decided to share the garland with them. He wants to cut two different wires so that the garland breaks up into three parts. Each part of the garland should shine equally, i. e. the sums of lamps' temperatures should be equal in each of the parts. Of course, each of the parts should be non-empty, i. e. each part should contain at least one lamp. Help Dima to find a suitable way to cut the garland, or determine that this is impossible. While examining the garland, Dima lifted it up holding by one of the lamps. Thus, each of the lamps, except the one he is holding by, is now hanging on some wire. So, you should print two lamp ids as the answer which denote that Dima should cut the wires these lamps are hanging on. Of course, the lamp Dima is holding the garland by can't be included in the answer. The first line contains single integer n ( 3 ≤ n ≤ 10 6 ) — the number of lamps in the garland. Then n lines follow. The i -th of them contain the information about the i -th lamp: the number lamp a i , it is hanging on (and 0 , if is there is no such lamp), and its temperature t i ( - 100 ≤ t i ≤ 100 ). The lamps are numbered from 1 to n . If there is no solution, print -1 . Otherwise print two integers — the indexes of the lamps which mean Dima should cut the wires they are hanging on. If there are multiple answers, print any of them. The garland and cuts scheme for the first example:

Tutorials

Codeforces Round #398 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
25574713 sergei.nosov C March 17, 2017, 2:07 p.m. OK D TESTS 43 1153 101785600 2000
24776589 TheHedgehog C Feb. 18, 2017, noon OK Delphi TESTS 43 545 41779200 2000
24779043 TheHedgehog C Feb. 18, 2017, 1:08 p.m. OK Delphi TESTS 43 748 41779200 2000
24776571 Gray_58 C Feb. 18, 2017, noon OK FPC TESTS 43 576 67686400 2000
24895430 AHTOH._. C Feb. 22, 2017, 2:28 p.m. OK FPC TESTS 43 608 37683200 2000
24774166 apt123 C Feb. 18, 2017, 11:04 a.m. OK FPC TESTS 43 608 57651200 2000
24776987 zhanggengchen C Feb. 18, 2017, 12:10 p.m. OK FPC TESTS 43 967 81817600 2000
28973186 anonymous.qsh C July 29, 2017, 3:16 p.m. OK GNU C TESTS 43 373 25907200 2000
24803223 jkxjkx1031 C Feb. 19, 2017, 1:42 p.m. OK GNU C TESTS 43 560 57958400 2000
24777227 mengbier233 C Feb. 18, 2017, 12:17 p.m. OK GNU C++ TESTS 43 171 46080000 2000
25027625 DFPMTS C Feb. 26, 2017, 3:58 a.m. OK GNU C++ TESTS 43 218 62156800 2000
41901422 vjudge5 C Aug. 20, 2018, 12:20 p.m. OK GNU C++ TESTS 43 233 32256000 2000
24777884 Vergil_LY C Feb. 18, 2017, 12:33 p.m. OK GNU C++ TESTS 43 233 66048000 2000
31217209 DoveChild C Oct. 11, 2017, 1:14 p.m. OK GNU C++ TESTS 43 233 72089600 2000
41896356 vjudge2 C Aug. 20, 2018, 9:40 a.m. OK GNU C++ TESTS 43 234 32256000 2000
40982450 ReaLNero1 C July 30, 2018, 6:26 p.m. OK GNU C++ TESTS 43 264 60006400 2000
38646503 vjudge5 C May 27, 2018, 3:41 a.m. OK GNU C++ TESTS 43 264 76083200 2000
41896568 vjudge4 C Aug. 20, 2018, 9:47 a.m. OK GNU C++ TESTS 43 265 32256000 2000
24778884 ftm2001 C Feb. 18, 2017, 1:02 p.m. OK GNU C++ TESTS 43 265 70144000 2000
47025240 vjudge2 C Dec. 15, 2018, 6:27 a.m. OK GNU C++11 TESTS 43 171 36556800 2000
46940798 luogu_bot5 C Dec. 12, 2018, 4:28 p.m. OK GNU C++11 TESTS 43 171 47820800 2000
46742966 pxv C Dec. 8, 2018, 4:52 a.m. OK GNU C++11 TESTS 43 171 48025600 2000
54831573 beng C May 30, 2019, 9:07 a.m. OK GNU C++11 TESTS 43 171 55808000 2000
45462904 xuqijie C Nov. 9, 2018, 2:50 a.m. OK GNU C++11 TESTS 43 202 47820800 2000
62054650 yugao C Oct. 7, 2019, 11:38 a.m. OK GNU C++11 TESTS 43 217 52019200 2000
54871538 luogu_bot1 C May 31, 2019, 9:30 a.m. OK GNU C++11 TESTS 43 217 52019200 2000
61448861 Dream-chasing_Juvenile C Sept. 29, 2019, 12:07 a.m. OK GNU C++11 TESTS 43 218 44544000 2000
57746119 Zed_knight C July 25, 2019, 1:05 p.m. OK GNU C++11 TESTS 43 218 52019200 2000
54618668 luogu_bot3 C May 25, 2019, 11:17 a.m. OK GNU C++11 TESTS 43 218 52019200 2000
53213316 davidberard C April 24, 2019, 7:04 a.m. OK GNU C++14 TESTS 43 249 68096000 2000
53213159 davidberard C April 24, 2019, 6:57 a.m. OK GNU C++14 TESTS 43 452 100352000 2000
24793761 basasuya C Feb. 19, 2017, 3:39 a.m. OK GNU C++14 TESTS 43 499 18329600 2000
24775122 afaji321 C Feb. 18, 2017, 11:36 a.m. OK GNU C++14 TESTS 43 499 130560000 2000
24780549 Splashing C Feb. 18, 2017, 2:01 p.m. OK GNU C++14 TESTS 43 514 18329600 2000
24774992 Egor.Lifar C Feb. 18, 2017, 11:34 a.m. OK GNU C++14 TESTS 43 514 122163200 2000
24794985 PrimeG C Feb. 19, 2017, 5:35 a.m. OK GNU C++14 TESTS 43 529 22016000 2000
36430692 easyhoon C March 20, 2018, 11:12 a.m. OK GNU C++14 TESTS 43 530 27340800 2000
29042817 RunningTime C July 31, 2017, 8:43 a.m. OK GNU C++14 TESTS 43 546 49971200 2000
24780943 olderor C Feb. 18, 2017, 2:15 p.m. OK GNU C++14 TESTS 43 561 34201600 2000
41608748 vjudge1 C Aug. 15, 2018, 5:06 a.m. OK GNU C++17 TESTS 43 265 48025600 2000
48523371 WDZRMPCBIT C Jan. 18, 2019, 7:43 a.m. OK GNU C++17 TESTS 43 514 60006400 2000
44104979 TobyCF C Oct. 11, 2018, 8:38 a.m. OK GNU C++17 TESTS 43 514 100454400 2000
57915125 127 C July 29, 2019, 12:32 a.m. OK GNU C++17 TESTS 43 529 52019200 2000
56180750 LeoRiether C June 27, 2019, 11:15 p.m. OK GNU C++17 TESTS 43 530 34713600 2000
53737649 QAQorz C May 4, 2019, 11:52 a.m. OK GNU C++17 TESTS 43 530 52019200 2000
56421744 vjudge2 C July 2, 2019, 7:40 a.m. OK GNU C++17 TESTS 43 545 92057600 2000
48319346 lyh1999 C Jan. 13, 2019, 8:23 a.m. OK GNU C++17 TESTS 43 561 76083200 2000
47489609 vjudge5 C Dec. 25, 2018, 11:17 a.m. OK GNU C++17 TESTS 43 576 47616000 2000
46940787 czsnb C Dec. 12, 2018, 4:28 p.m. OK GNU C++17 TESTS 43 576 48230400 2000
25590425 chojh1222 C March 18, 2017, 5:55 a.m. OK Java 8 TESTS 43 451 95641600 2000
38565341 Ajudiya_13 C May 23, 2018, 2:40 p.m. OK Java 8 TESTS 43 514 72192000 2000
24812070 Hardik.decoder C Feb. 19, 2017, 11 p.m. OK Java 8 TESTS 43 560 95436800 2000
47492883 libra8z C Dec. 25, 2018, 1:17 p.m. OK Java 8 TESTS 43 561 73113600 2000
25240870 garnacha C March 5, 2017, 10:28 a.m. OK Java 8 TESTS 43 608 64204800 2000
25763879 BelkaVest C March 24, 2017, 5:53 a.m. OK Java 8 TESTS 43 639 62873600 2000
25694058 gpita C March 21, 2017, 3:33 p.m. OK Java 8 TESTS 43 670 57753600 2000
25013752 Ahmad_Elsagheer C Feb. 25, 2017, 1:31 p.m. OK Java 8 TESTS 43 701 85606400 2000
25653741 eriksuenderhauf C March 19, 2017, 7:09 p.m. OK Java 8 TESTS 43 763 95539200 2000
25789978 niting112 C March 25, 2017, 6:46 a.m. OK Java 8 TESTS 43 764 85606400 2000
24869536 azukun C Feb. 21, 2017, 11:28 a.m. OK MS C# TESTS 43 342 41472000 2000
24869644 azukun C Feb. 21, 2017, 11:33 a.m. OK MS C# TESTS 43 717 41779200 2000
24782886 og.kostya C Feb. 18, 2017, 3:31 p.m. OK MS C# TESTS 43 951 110182400 2000
36121525 vjudge4 C March 9, 2018, 3:15 p.m. OK MS C++ TESTS 43 374 29388800 2000
29774707 vjudge5 C Aug. 25, 2017, 9:10 a.m. OK MS C++ TESTS 43 389 24064000 2000
28930601 nka_kun C July 27, 2017, 12:56 p.m. OK MS C++ TESTS 43 390 48947200 2000
53822244 vjudge3 C May 6, 2019, 1:50 p.m. OK MS C++ TESTS 43 420 40038400 2000
47491345 vjudge5 C Dec. 25, 2018, 12:19 p.m. OK MS C++ TESTS 43 436 48025600 2000
48522229 vjudge3 C Jan. 18, 2019, 7:08 a.m. OK MS C++ TESTS 43 452 56012800 2000
46045244 vjudge5 C Nov. 22, 2018, 12:53 a.m. OK MS C++ TESTS 43 468 40038400 2000
46106134 vjudge5 C Nov. 23, 2018, 9:19 a.m. OK MS C++ TESTS 43 482 56012800 2000
46106175 vjudge5 C Nov. 23, 2018, 9:21 a.m. OK MS C++ TESTS 43 483 52019200 2000
46106104 vjudge2 C Nov. 23, 2018, 9:18 a.m. OK MS C++ TESTS 43 483 56012800 2000
57192315 vjudge2 C July 17, 2019, 11:05 a.m. OK MS C++ 2017 TESTS 43 624 192307200 2000
56368211 LowbieH C July 1, 2019, 1:27 a.m. OK MS C++ 2017 TESTS 43 686 48025600 2000
68063272 vjudge2 C Jan. 2, 2020, 6:01 a.m. OK MS C++ 2017 TESTS 43 732 72089600 2000
56481184 fishdog C July 3, 2019, 4:09 p.m. OK MS C++ 2017 TESTS 43 1138 60108800 2000
67146813 RoemonKing C Dec. 18, 2019, 9:11 a.m. OK MS C++ 2017 TESTS 43 1778 56115200 2000
24782778 mio_h C Feb. 18, 2017, 3:26 p.m. OK Rust TESTS 43 685 112844800 2000
24818121 tubo28 C Feb. 20, 2017, 8:42 a.m. OK Rust TESTS 43 1825 188313600 2000
24817896 kobae964 C Feb. 20, 2017, 8:31 a.m. OK Rust TESTS 43 1840 82534400 2000
24817646 kobae964 C Feb. 20, 2017, 8:15 a.m. OK Rust TESTS 43 1981 119705600 2000

remove filters

Back to search problems