Codeforces Round 701 (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
1485 Codeforces Round 701 (Div. 2) FINISHED False 7200 124038563 Feb. 12, 2021, 2:50 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1373 ) E Move and Swap PROGRAMMING dp greedy trees 2500

B"You are given n - 1 integers a_2, ... , a_n and a tree with n vertices rooted at vertex 1 . The leaves are all at the same distance d from the root. Recall that a tree is a connected undirected graph without cycles. The distance between two vertices is the number of edges on the simple path between them. All non-root vertices with degree 1 are leaves. If vertices s and f are connected by an edge and the distance of f from the root is greater than the distance of s from the root, then f is called a child of s . Initially, there are a red coin and a blue coin on the vertex 1 . Let r be the vertex where the red coin is and let b be the vertex where the blue coin is. You should make d moves. A move consists of three steps: Note that r and b can be equal at any time, and there is no number written on the root. After each move, you gain |a_r - a_b| points. What's the maximum number of points you can gain after d moves? The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains a single integer n ( 2 <= q n <= q 2 cdot 10^5 ) -- the number of vertices in the tree. The second line of each test case contains n-1 integers v_2, v_3, ... , v_n ( 1 <= q v_i <= q n , v_i neq i ) -- the i -th of them indicates that there is an edge between vertices i and v_i . It is guaranteed, that these edges form a tree. The third line of each test case contains n-1 integers a_2, ... , a_n ( 1 <= q a_i <= q 10^9 ) -- the numbers written on the vertices. It is guaranteed that the sum of n for all test cases does not exceed 2 cdot 10^5 . For each test case, print a single integer: the maximum number of points you can gain after d moves. In the first test case, an optimal solution is to: The tot"...

Tutorials

Editorial of Codeforces Round #701 (Div. 2)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
107230972 mts_246 E Feb. 12, 2021, 5:26 p.m. OK GNU C++11 TESTS 35 62 8396800 2500
107253383 Gaoyx E Feb. 13, 2021, 4:35 a.m. OK GNU C++11 TESTS 35 93 15564800 2500
107248111 seeeagull E Feb. 13, 2021, 1:16 a.m. OK GNU C++11 TESTS 35 108 15974400 2500
107255005 zyz07 E Feb. 13, 2021, 5:16 a.m. OK GNU C++11 TESTS 35 124 13721600 2500
107254009 Dreamfarer E Feb. 13, 2021, 4:54 a.m. OK GNU C++11 TESTS 35 124 13721600 2500
107220443 ykl E Feb. 12, 2021, 4:20 p.m. OK GNU C++11 TESTS 35 124 14438400 2500
107221273 oisdoaiu E Feb. 12, 2021, 4:23 p.m. OK GNU C++11 TESTS 35 124 15257600 2500
107253126 onglu1 E Feb. 13, 2021, 4:27 a.m. OK GNU C++11 TESTS 35 139 25907200 2500
107225854 469762049 E Feb. 12, 2021, 4:41 p.m. OK GNU C++11 TESTS 35 140 15155200 2500
107225053 Mr_Eight E Feb. 12, 2021, 4:38 p.m. OK GNU C++11 TESTS 35 140 18636800 2500
107239537 WiwiHo E Feb. 12, 2021, 7:26 p.m. OK GNU C++14 TESTS 35 171 16588800 2500
107229771 TranLeHiep E Feb. 12, 2021, 5:20 p.m. OK GNU C++14 TESTS 35 186 16179200 2500
107243122 mintchoco03 E Feb. 12, 2021, 8:58 p.m. OK GNU C++14 TESTS 35 187 16998400 2500
107232946 NewSession E Feb. 12, 2021, 5:43 p.m. OK GNU C++14 TESTS 35 187 18124800 2500
107246858 SuperJ6 E Feb. 12, 2021, 11:58 p.m. OK GNU C++14 TESTS 35 187 18944000 2500
107230073 MrDecomposition E Feb. 12, 2021, 5:21 p.m. OK GNU C++14 TESTS 35 187 49152000 2500
107229814 askd E Feb. 12, 2021, 5:20 p.m. OK GNU C++14 TESTS 35 202 13926400 2500
107234427 stefdasca E Feb. 12, 2021, 6:01 p.m. OK GNU C++14 TESTS 35 202 15360000 2500
107244258 marcOS E Feb. 12, 2021, 9:38 p.m. OK GNU C++14 TESTS 35 202 16896000 2500
107246038 Mast3rmind E Feb. 12, 2021, 11:08 p.m. OK GNU C++14 TESTS 35 202 18534400 2500
107236871 iaNTU E Feb. 12, 2021, 6:39 p.m. OK GNU C++17 TESTS 35 140 16998400 2500
107256558 YoungK E Feb. 13, 2021, 5:48 a.m. OK GNU C++17 TESTS 35 171 13516800 2500
107237763 Blondie E Feb. 12, 2021, 6:53 p.m. OK GNU C++17 TESTS 35 171 14438400 2500
107251677 Normie28 E Feb. 13, 2021, 3:42 a.m. OK GNU C++17 TESTS 35 186 23040000 2500
107255506 abc864197532 E Feb. 13, 2021, 5:27 a.m. OK GNU C++17 TESTS 35 187 15462400 2500
107223199 Ronnie007 E Feb. 12, 2021, 4:31 p.m. OK GNU C++17 TESTS 35 187 15974400 2500
107245735 tupside E Feb. 12, 2021, 10:50 p.m. OK GNU C++17 TESTS 35 187 17817600 2500
107223402 _Ore_ E Feb. 12, 2021, 4:32 p.m. OK GNU C++17 TESTS 35 187 18329600 2500
107232058 realcomplex E Feb. 12, 2021, 5:35 p.m. OK GNU C++17 TESTS 35 187 20172800 2500
107218834 i3Cheese E Feb. 12, 2021, 4:13 p.m. OK GNU C++17 TESTS 35 202 15155200 2500
107245263 PurpleCrayon E Feb. 12, 2021, 10:25 p.m. OK GNU C++17 (64) TESTS 35 155 24678400 2500
107244180 Juvitus E Feb. 12, 2021, 9:36 p.m. OK GNU C++17 (64) TESTS 35 155 30310400 2500
107222855 soicon E Feb. 12, 2021, 4:30 p.m. OK GNU C++17 (64) TESTS 35 156 25088000 2500
107248310 njwrz E Feb. 13, 2021, 1:27 a.m. OK GNU C++17 (64) TESTS 35 156 26112000 2500
107248211 laowuniubi E Feb. 13, 2021, 1:23 a.m. OK GNU C++17 (64) TESTS 35 156 26112000 2500
107252217 haruki_K E Feb. 13, 2021, 3:58 a.m. OK GNU C++17 (64) TESTS 35 171 21811200 2500
107227900 Pecco E Feb. 12, 2021, 4:48 p.m. OK GNU C++17 (64) TESTS 35 171 22425600 2500
107244063 little_misfortune E Feb. 12, 2021, 9:31 p.m. OK GNU C++17 (64) TESTS 35 171 23040000 2500
107251293 Origenes E Feb. 13, 2021, 3:30 a.m. OK GNU C++17 (64) TESTS 35 171 23859200 2500
107249078 smax E Feb. 13, 2021, 2:06 a.m. OK GNU C++17 (64) TESTS 35 171 24883200 2500
107245664 clyring E Feb. 12, 2021, 10:46 p.m. OK Haskell TESTS 35 577 50585600 2500
107230211 uwi E Feb. 12, 2021, 5:21 p.m. OK Java 11 TESTS 35 296 6656000 2500
107232825 sarthakmanna E Feb. 12, 2021, 5:42 p.m. OK Java 11 TESTS 35 780 47308800 2500
107220718 SecondThread E Feb. 12, 2021, 4:21 p.m. OK Java 11 TESTS 35 951 67891200 2500
107224513 Kiri8128 E Feb. 12, 2021, 4:36 p.m. OK PyPy 3 TESTS 35 1044 50278400 2500
107238388 yinuowang E Feb. 12, 2021, 7:03 p.m. OK PyPy 3 TESTS 35 1075 73113600 2500
107236932 david-mm E Feb. 12, 2021, 6:40 p.m. OK PyPy 3 TESTS 35 1138 72089600 2500
107232489 nwi E Feb. 12, 2021, 5:39 p.m. OK Python 2 TESTS 35 920 31539200 2500
107255743 sh1194 E Feb. 13, 2021, 5:32 a.m. OK Python 3 TESTS 35 1777 44441600 2500
107255541 sh1194 E Feb. 13, 2021, 5:28 a.m. OK Python 3 TESTS 35 1872 44851200 2500
107255403 sh1194 E Feb. 13, 2021, 5:25 a.m. OK Python 3 TESTS 35 1903 44441600 2500
107255481 sh1194 E Feb. 13, 2021, 5:27 a.m. OK Python 3 TESTS 35 1949 44441600 2500
107237022 hiratai E Feb. 12, 2021, 6:42 p.m. OK Rust TESTS 35 233 32768000 2500
107225335 ocamler E Feb. 12, 2021, 4:39 p.m. OK Rust TESTS 35 264 24371200 2500
107220510 sansen E Feb. 12, 2021, 4:20 p.m. OK Rust TESTS 35 935 29798400 2500

remove filters

Back to search problems