Codeforces Round 157 (Div. 1)

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
258 Codeforces Round 157 (Div. 1) FINISHED False 7200 375632999 Dec. 22, 2012, 3:30 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1129 ) E Little Elephant and Tree PROGRAMMING data structures dfs and similar trees 2400

B"The Little Elephant loves trees very much, he especially loves root trees. He's got a tree consisting of n nodes (the nodes are numbered from 1 to n), with root at node number 1. Each node of the tree contains some list of numbers which initially is empty. The Little Elephant wants to apply m operations. On the i-th operation (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89i xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89m) he first adds number i to lists of all nodes of a subtree with the root in node number ai, and then he adds number i to lists of all nodes of the subtree with root in node bi. After applying all operations the Little Elephant wants to count for each node i number ci -- the number of integers j (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89j xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n; j xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89i), such that the lists of the i-th and the j-th nodes contain at least one common number. Help the Little Elephant, count numbers ci for him. The first line contains two integers n and m (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x89m xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) -- the number of the tree nodes and the number of operations. Each of the following n xe2 x80 x89- xe2 x80 x891 lines contains two space-separated integers, ui and vi (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ui, xe2 x80 x89vi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x89ui xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89vi), that mean that there is an edge between nodes number ui and vi. Each of the following m lines contains two space-separated integers, ai and bi (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai, xe2 x80 x89bi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n, xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89bi), that stand for the indexes of the nodes in the i-th operation. It is guaranteed that the given graph is an undirected tree. In a single line print n space-separated integers -- c1, xe2 x80 x89c2, xe2 x80 x89..., xe2 x80 x89cn."...

Tutorials

Codeforces Round #157 — Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
2868151 conan_doyle95 E Jan. 3, 2013, 3:50 a.m. OK FPC TESTS 42 375 12083200 2400
3999514 lilinyi001 E July 1, 2013, 12:28 p.m. OK FPC TESTS 42 625 36761600 2400
2821971 con_nha_ngheo E Dec. 24, 2012, 10:44 a.m. OK FPC TESTS 42 718 12390400 2400
2815195 vlad107 E Dec. 22, 2012, 5:24 p.m. OK FPC TESTS 41 1828 44544000 2400
2863011 E478 E Jan. 1, 2013, 9 a.m. OK GNU C TESTS 42 484 10240000 2400
2904223 ryanaaa E Jan. 11, 2013, 7:05 a.m. OK GNU C++ TESTS 42 375 208896000 2400
2815936 ACube E Dec. 22, 2012, 6:15 p.m. OK GNU C++ TESTS 41 405 15155200 2400
2868167 chnlich E Jan. 3, 2013, 4:06 a.m. OK GNU C++ TESTS 42 406 127488000 2400
2815647 pty E Dec. 22, 2012, 6:03 p.m. OK GNU C++ TESTS 41 421 43520000 2400
8042973 wjh720 E Oct. 1, 2014, 5:33 a.m. OK GNU C++ TESTS 42 436 237465600 2400
2827762 ByFlash E Dec. 26, 2012, 5:28 a.m. OK GNU C++ TESTS 42 453 9830400 2400
40990357 ReaLNero1 E July 30, 2018, 11:50 p.m. OK GNU C++ TESTS 42 466 208793600 2400
8841371 __Dante E Nov. 25, 2014, 1:17 a.m. OK GNU C++ TESTS 42 466 216473600 2400
2827824 ByFlash E Dec. 26, 2012, 6 a.m. OK GNU C++ TESTS 42 468 9830400 2400
2819416 Yousef_Salama E Dec. 23, 2012, 2:32 p.m. OK GNU C++ TESTS 42 468 10342400 2400
3414087 UESTC_ElemeNtLz E March 28, 2013, 4:59 a.m. OK GNU C++0x TESTS 42 577 15564800 2400
3414055 UESTC_ElemeNtLz E March 28, 2013, 4:49 a.m. OK GNU C++0x TESTS 42 578 21913600 2400
3414054 UESTC_ElemeNtLz E March 28, 2013, 4:48 a.m. OK GNU C++0x TESTS 42 593 25190400 2400
7645091 wanbo E Aug. 30, 2014, 1:40 p.m. OK GNU C++0x TESTS 42 622 14950400 2400
2877111 dc. E Jan. 6, 2013, 8:36 a.m. OK GNU C++0x TESTS 42 639 22016000 2400
6012846 yutaka1999 E March 14, 2014, 3:25 a.m. OK GNU C++0x TESTS 42 654 14028800 2400
3424654 hex539 E March 30, 2013, 9:51 p.m. OK GNU C++0x TESTS 42 656 154112000 2400
2819830 whimsycwd E Dec. 23, 2012, 5:06 p.m. OK GNU C++0x TESTS 42 671 15872000 2400
4303047 harhrayr E Aug. 17, 2013, 11:24 a.m. OK GNU C++0x TESTS 42 686 20070400 2400
2819256 dhh1995 E Dec. 23, 2012, 1:36 p.m. OK GNU C++0x TESTS 42 687 15872000 2400
61727167 rainboy E Oct. 2, 2019, 3:47 p.m. OK GNU C11 TESTS 42 1466 20480000 2400
13016533 cq_phqg E Sept. 16, 2015, 5:50 a.m. OK GNU C++11 TESTS 42 404 8908800 2400
26444978 RNS_MHB E April 17, 2017, 3:59 a.m. OK GNU C++11 TESTS 42 404 133120000 2400
13016699 cq_phqg E Sept. 16, 2015, 6:12 a.m. OK GNU C++11 TESTS 42 434 11673600 2400
12692742 andrew.volchek E Aug. 25, 2015, 7:49 a.m. OK GNU C++11 TESTS 42 498 17920000 2400
17819721 joisino E May 9, 2016, 12:02 p.m. OK GNU C++11 TESTS 42 530 20377600 2400
12263683 strawbreey E July 29, 2015, 11:28 a.m. OK GNU C++11 TESTS 42 560 13619200 2400
45846885 Jonothor_Darry E Nov. 16, 2018, 8:06 p.m. OK GNU C++11 TESTS 42 590 13619200 2400
41532463 w446506278 E Aug. 12, 2018, 3:20 p.m. OK GNU C++11 TESTS 42 624 12697600 2400
17688160 2020.01.09_Restart E May 2, 2016, 11:21 a.m. OK GNU C++11 TESTS 42 624 16076800 2400
19422391 totsamyzed E July 26, 2016, 12:24 p.m. OK GNU C++11 TESTS 42 654 43622400 2400
26820379 fofao_funk E May 3, 2017, 2:15 p.m. OK GNU C++14 TESTS 42 592 13721600 2400
57818861 stefdasca E July 26, 2019, 9:28 p.m. OK GNU C++14 TESTS 42 622 16896000 2400
58788782 vjudge4 E Aug. 14, 2019, 1:12 a.m. OK GNU C++14 TESTS 42 686 12390400 2400
64259837 Mohammad.H915 E Nov. 4, 2019, 4:14 p.m. OK GNU C++14 TESTS 42 686 13824000 2400
26373388 SoSad E April 15, 2017, 7:29 a.m. OK GNU C++14 TESTS 42 716 15872000 2400
40589324 AryanSM E July 20, 2018, 8:40 p.m. OK GNU C++14 TESTS 42 716 20172800 2400
31315853 unknown_one E Oct. 14, 2017, 3:18 p.m. OK GNU C++14 TESTS 42 746 19251200 2400
38605954 tmwilliamlin168 E May 25, 2018, 10:20 a.m. OK GNU C++14 TESTS 42 748 12800000 2400
32061894 Odin- E Nov. 4, 2017, 7:16 p.m. OK GNU C++14 TESTS 42 748 14028800 2400
40780265 vjudge5 E July 26, 2018, 1:23 p.m. OK GNU C++14 TESTS 42 748 27750400 2400
64295501 jkchen E Nov. 5, 2019, 8:29 a.m. OK GNU C++17 TESTS 42 498 121753600 2400
64295407 jkchen E Nov. 5, 2019, 8:27 a.m. OK GNU C++17 TESTS 42 498 137830400 2400
64294953 jkchen E Nov. 5, 2019, 8:19 a.m. OK GNU C++17 TESTS 42 560 169881600 2400
66520681 .I. E Dec. 8, 2019, 10:10 p.m. OK GNU C++17 TESTS 42 716 18534400 2400
50535390 NothingToSeeHere E Feb. 26, 2019, 3:28 p.m. OK GNU C++17 TESTS 42 778 13824000 2400
52547690 CaroLinda E April 9, 2019, 11:38 p.m. OK GNU C++17 TESTS 42 778 15872000 2400
64582808 yuxizi E Nov. 9, 2019, 12:34 p.m. OK GNU C++17 TESTS 42 780 12697600 2400
64582966 yuxizi E Nov. 9, 2019, 12:36 p.m. OK GNU C++17 TESTS 42 780 15974400 2400
51420156 ruo E March 17, 2019, 4:05 p.m. OK GNU C++17 TESTS 42 810 14233600 2400
59660820 igba E Aug. 29, 2019, 12:25 p.m. OK GNU C++17 TESTS 42 810 18124800 2400
2825685 uwi E Dec. 25, 2012, 1:05 p.m. OK Java 6 TESTS 42 1125 307200 2400
2812511 Petr E Dec. 22, 2012, 4:22 p.m. OK Java 6 TESTS 41 1359 44441600 2400
2825665 uwi E Dec. 25, 2012, 1 p.m. OK Java 6 TESTS 42 1453 14131200 2400
2814540 Bugman E Dec. 22, 2012, 5:06 p.m. OK Java 6 TESTS 41 1640 56422400 2400
2814027 FattyChicken E Dec. 22, 2012, 4:52 p.m. OK Java 7 TESTS 41 1125 16588800 2400
2814927 cerealguy E Dec. 22, 2012, 5:17 p.m. OK Java 7 TESTS 41 1578 40140800 2400
2815843 qwerty787788 E Dec. 22, 2012, 6:10 p.m. OK Java 7 TESTS 41 1656 52633600 2400
2818208 Mex-Mans E Dec. 23, 2012, 7:43 a.m. OK Java 7 TESTS 42 1718 47513600 2400
7811062 AlexFetisov E Sept. 16, 2014, 3:53 p.m. OK Java 8 TESTS 42 2152 3686400 2400
61727166 Dukkha E Oct. 2, 2019, 3:47 p.m. OK Java 8 TESTS 42 2340 34099200 2400
19283581 Sumeet.Varma E July 20, 2016, 3:17 p.m. OK Java 8 TESTS 42 2524 62156800 2400
25638679 leign E March 19, 2017, 7:23 a.m. OK Mono C# TESTS 42 1402 33382400 2400
2815642 RAD E Dec. 22, 2012, 6:03 p.m. OK MS C++ TESTS 41 437 65638400 2400
2907612 zzx E Jan. 12, 2013, 12:05 p.m. OK MS C++ TESTS 42 484 15872000 2400
2822393 seen E Dec. 24, 2012, 1:06 p.m. OK MS C++ TESTS 42 671 21913600 2400
3732880 XilinX E May 18, 2013, 9:22 a.m. OK MS C++ TESTS 42 718 18432000 2400
2905311 xtalclr E Jan. 11, 2013, 2:47 p.m. OK MS C++ TESTS 42 843 20684800 2400
2818707 Fdg E Dec. 23, 2012, 10:07 a.m. OK MS C++ TESTS 42 951 34713600 2400
2856698 Dabek E Dec. 30, 2012, 11:22 a.m. OK MS C++ TESTS 42 953 15462400 2400
2816442 YX201314 E Dec. 22, 2012, 7:02 p.m. OK MS C++ TESTS 42 953 18227200 2400
2818704 Fdg E Dec. 23, 2012, 10:05 a.m. OK MS C++ TESTS 42 953 41881600 2400
2815654 Fdg E Dec. 22, 2012, 6:03 p.m. OK MS C++ TESTS 41 953 46694400 2400
2875798 Darooha E Jan. 5, 2013, 5:14 p.m. OK Ocaml TESTS 42 671 16691200 2400
2875794 Darooha E Jan. 5, 2013, 5:12 p.m. OK Ocaml TESTS 42 1421 17715200 2400

remove filters

Back to search problems