Codeforces Round 221 (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
375 Codeforces Round 221 (Div. 1) FINISHED False 7200 343929599 Dec. 24, 2013, 2 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 412 ) E Red and Black Tree PROGRAMMING dp implementation math 3000

B'You have a weighted tree, consisting of n vertices. Each vertex is either painted black or is painted red. A red and black tree is called beautiful, if for any its vertex we can find a black vertex at distance at most x. The distance between two nodes is the shortest path between them. You have a red and black tree. Your task is to make it beautiful in the minimum number of color swap operations. In one color swap operation, you can choose two vertices of different colors and paint each of them the other color. In other words, if you choose a red vertex p and a black vertex q, then in one operation you are allowed to paint p black and paint q red. Print the minimum number of required actions. The first line contains two integers n and x (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89500; 1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89x xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109). The next line contains n integers, each of them is either a zero or one. If the i-th number equals 1, then vertex i of the tree is black, otherwise vertex i is red. Next n xe2 x80 x89- xe2 x80 x891 lines contain the tree edges. The j-th line contains integers uj vj wj (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89uj, xe2 x80 x89vj xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n; uj xe2 x80 x89 xe2 x89 xa0 xe2 x80 x89vj; 1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89wj xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109) which means that the tree has an edge of weight wj between vertices vj and uj. Assume that the tree vertices are numbered from 1 to n. Print a single integer -- the minimum number of required swap operations. If it is impossible to get a beautiful tree at any number of operations, print -1.'...

Tutorials

Codeforces Round #221 Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
11615676 frozenstarlight E June 17, 2015, 7:02 a.m. OK GNU C++ TESTS 73 15 1126400 3000
15143600 HappyNewYearMike E Dec. 31, 2015, 11:25 p.m. OK GNU C++ TESTS 73 15 2048000 3000
11573918 Shinta E June 13, 2015, 8:41 p.m. OK GNU C++ TESTS 73 15 2048000 3000
6246377 black_horse2014 E April 3, 2014, 12:38 a.m. OK GNU C++ TESTS 73 15 2252800 3000
25008945 cilebritain E Feb. 25, 2017, 9:59 a.m. OK GNU C++ TESTS 73 15 22220800 3000
11615435 frozenstarlight E June 17, 2015, 6:36 a.m. OK GNU C++ TESTS 73 30 3072000 3000
16544333 KFDong E March 6, 2016, 3:52 a.m. OK GNU C++ TESTS 73 30 3174400 3000
7058555 duzfan E July 10, 2014, 12:13 p.m. OK GNU C++ TESTS 73 30 4096000 3000
40989246 ReaLNero1 E July 30, 2018, 10:44 p.m. OK GNU C++ TESTS 73 31 2048000 3000
11615444 frozenstarlight E June 17, 2015, 6:38 a.m. OK GNU C++ TESTS 73 31 2048000 3000
5523033 ruc_acme E Dec. 26, 2013, 6:38 a.m. OK GNU C++0x TESTS 73 15 2252800 3000
6458233 dc. E April 24, 2014, 4:46 a.m. OK GNU C++0x TESTS 73 30 3276800 3000
6458202 dc. E April 24, 2014, 4:37 a.m. OK GNU C++0x TESTS 73 358 3276800 3000
5521044 Zuza E Dec. 25, 2013, 7:19 p.m. OK GNU C++0x TESTS 73 390 8704000 3000
5520784 Zuza E Dec. 25, 2013, 6:05 p.m. OK GNU C++0x TESTS 73 390 251699200 3000
7408407 soda_beta E Aug. 9, 2014, 7:56 p.m. OK GNU C++0x TESTS 73 514 11878400 3000
5665435 dc. E Jan. 12, 2014, 1:21 p.m. OK GNU C++0x TESTS 73 514 261632000 3000
7412104 soda_beta E Aug. 10, 2014, 8:18 a.m. OK GNU C++0x TESTS 73 561 145715200 3000
17905499 Yazan_Eagle E May 14, 2016, 12:43 p.m. OK GNU C++11 TESTS 73 15 10240000 3000
20450580 wwyyxx E Sept. 8, 2016, 3:43 a.m. OK GNU C++11 TESTS 73 30 2048000 3000
17284905 lbn187 E April 12, 2016, 1:55 a.m. OK GNU C++11 TESTS 73 30 2048000 3000
17905449 liuguangzhe E May 14, 2016, 12:40 p.m. OK GNU C++11 TESTS 73 30 10240000 3000
60707535 zxyoi E Sept. 17, 2019, 6:13 a.m. OK GNU C++11 TESTS 73 31 2048000 3000
40116139 Control_xl E July 9, 2018, 2:46 p.m. OK GNU C++11 TESTS 73 31 2048000 3000
39940960 static_check E July 4, 2018, 3:12 a.m. OK GNU C++11 TESTS 73 31 2048000 3000
39940867 static_check E July 4, 2018, 3:07 a.m. OK GNU C++11 TESTS 73 31 2048000 3000
39940679 static_check E July 4, 2018, 2:56 a.m. OK GNU C++11 TESTS 73 31 2048000 3000
39939963 static_check E July 4, 2018, 2:12 a.m. OK GNU C++11 TESTS 73 31 2048000 3000
23660788 Ali.Pi E Jan. 9, 2017, 6:24 a.m. OK GNU C++14 TESTS 73 30 3993600 3000
39817002 africamonkey E July 1, 2018, 9:15 a.m. OK GNU C++14 TESTS 73 31 2048000 3000
40055860 Draymond E July 7, 2018, 8:47 a.m. OK GNU C++14 TESTS 73 31 2252800 3000
24733521 kiiiiii E Feb. 17, 2017, 7:35 a.m. OK GNU C++14 TESTS 73 31 3993600 3000
56729978 Scut82 E July 9, 2019, 12:04 a.m. OK GNU C++14 TESTS 73 31 4300800 3000
56729974 Scut82 E July 9, 2019, 12:03 a.m. OK GNU C++14 TESTS 73 31 4300800 3000
49551856 wleung_bvg E Feb. 7, 2019, 6:39 a.m. OK GNU C++14 TESTS 73 31 6553600 3000
49551122 wleung_bvg E Feb. 7, 2019, 6:02 a.m. OK GNU C++14 TESTS 73 31 6553600 3000
49508007 wleung_bvg E Feb. 5, 2019, 6:32 p.m. OK GNU C++14 TESTS 73 31 6553600 3000
44891061 Quang E Oct. 26, 2018, 3:20 a.m. OK GNU C++14 TESTS 73 31 8806400 3000
40185151 HHL E July 11, 2018, 12:38 a.m. OK GNU C++17 TESTS 73 31 2252800 3000
44095507 Als123 E Oct. 10, 2018, 11:33 p.m. OK GNU C++17 TESTS 73 46 4403200 3000
46245517 fcwww E Nov. 26, 2018, 11:10 a.m. OK GNU C++17 TESTS 73 46 6451200 3000
51316468 vjudge3 E March 15, 2019, 12:57 a.m. OK GNU C++17 TESTS 73 62 4096000 3000
51318723 vjudge3 E March 15, 2019, 3:59 a.m. OK GNU C++17 TESTS 73 109 3072000 3000
51318521 616156 E March 15, 2019, 3:40 a.m. OK GNU C++17 TESTS 73 124 3072000 3000
44615521 Benq E Oct. 21, 2018, 12:54 a.m. OK GNU C++17 TESTS 73 140 12595200 3000
40135660 shiyuchong E July 9, 2018, 4:42 p.m. OK GNU C++17 TESTS 73 187 2457600 3000
52808465 YouKn0wWho E April 16, 2019, 6:55 a.m. OK GNU C++17 TESTS 73 280 14848000 3000
65717516 abc473848880 E Nov. 25, 2019, 5:18 p.m. OK GNU C++17 TESTS 73 280 259174400 3000
5635111 alexey.kasatkin E Jan. 7, 2014, 11:34 p.m. OK Java 7 TESTS 73 234 409600 3000
7510099 Los_Angelos_Laycurse E Aug. 19, 2014, 4:22 p.m. OK MS C++ TESTS 73 296 257843200 3000
6247425 blueseen E April 3, 2014, 5:49 a.m. OK MS C++ TESTS 73 826 258457600 3000

remove filters

Back to search problems