Codeforces Round 858 (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
1806 Codeforces Round 858 (Div. 2) FINISHED False 8100 58125262 March 18, 2023, 12:05 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 2924 ) E Tree Master PROGRAMMING brute force data structures dfs and similar hashing trees

B'You are given a tree with n weighted vertices labeled from 1 to n rooted at vertex 1 . The parent of vertex i is p_i and the weight of vertex i is a_i . For convenience, define p_1=0 . For two vertices x and y of the same depth ^ dagger , define f(x,y) as follows: You will process q queries. In the i -th query, you are given two integers x_i and y_i and you need to calculate f(x_i,y_i) . ^ dagger The depth of vertex v is the number of edges on the unique simple path from the root of the tree to vertex v . The first line contains two integers n and q ( 2 <= n <= 10^5 ; 1 <= q <= 10^5 ). The second line contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10^5 ). The third line contains n-1 integers p_2, ldots, p_n ( 1 <= p_i < i ). Each of the next q lines contains two integers x_i and y_i ( 1 <= x_i,y_i <= n ). It is guaranteed that x_i and y_i are of the same depth. Output q lines, the i -th line contains a single integer, the value of f(x_i,y_i) . Consider the first example: In the first query, the answer is a_4 cdot a_5+a_3 cdot a_3+a_2 cdot a_2+a_1 cdot a_1=3+4+25+1=33 . In the second query, the answer is a_6 cdot a_6+a_2 cdot a_2+a_1 cdot a_1=1+25+1=27 . '...

Tutorials

Codeforces Round #858 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
197990932 Tdyx E March 18, 2023, 4:21 p.m. OK C# 10 TESTS 56 1762 841420800
197980802 bktl1love E March 18, 2023, 3:12 p.m. OK GNU C++14 TESTS 56 187 12492800
197987791 Su_Zipei E March 18, 2023, 3:58 p.m. OK GNU C++14 TESTS 56 234 9932800
197972228 Su_Zipei E March 18, 2023, 2:17 p.m. OK GNU C++14 TESTS 56 249 8396800
197987740 Su_Zipei E March 18, 2023, 3:57 p.m. OK GNU C++14 TESTS 56 249 9932800
197980874 bktl1love E March 18, 2023, 3:12 p.m. OK GNU C++14 TESTS 56 265 11776000
197992213 aonbel E March 18, 2023, 4:31 p.m. OK GNU C++14 TESTS 57 296 92364800
197979833 a757403 E March 18, 2023, 3:06 p.m. OK GNU C++14 TESTS 56 311 7782400
197971453 RiziR E March 18, 2023, 2:15 p.m. OK GNU C++14 TESTS 56 327 16793600
197992041 aonbel E March 18, 2023, 4:30 p.m. OK GNU C++14 TESTS 57 327 92364800
197991893 aonbel E March 18, 2023, 4:29 p.m. OK GNU C++14 TESTS 57 327 93491200
197989122 alex0101 E March 18, 2023, 4:08 p.m. OK GNU C++17 TESTS 56 234 9932800
197990230 alex0101 E March 18, 2023, 4:16 p.m. OK GNU C++17 TESTS 56 265 9932800
197990079 alex0101 E March 18, 2023, 4:15 p.m. OK GNU C++17 TESTS 56 265 9932800
197989826 alex0101 E March 18, 2023, 4:13 p.m. OK GNU C++17 TESTS 56 265 12083200
197988788 alex0101 E March 18, 2023, 4:05 p.m. OK GNU C++17 TESTS 56 280 8294400
197989744 alex0101 E March 18, 2023, 4:12 p.m. OK GNU C++17 TESTS 56 280 8704000
197980776 friendless E March 18, 2023, 3:12 p.m. OK GNU C++17 TESTS 56 296 116838400
197987999 qqzj E March 18, 2023, 3:59 p.m. OK GNU C++17 TESTS 56 342 7680000
197980645 friendless E March 18, 2023, 3:11 p.m. OK GNU C++17 TESTS 56 343 116838400
197976369 yzyyylx E March 18, 2023, 2:49 p.m. OK GNU C++17 TESTS 56 358 213811200
197977937 dimss E March 18, 2023, 2:56 p.m. OK GNU C++17 (64) TESTS 56 436 727040000
197975849 Lucina E March 18, 2023, 2:47 p.m. OK GNU C++17 (64) TESTS 56 498 493465600
198031310 Scarlett_boy E March 19, 2023, 1:12 a.m. OK GNU C++17 (64) TESTS 61 514 70758400
197997176 LinkWish E March 18, 2023, 5:09 p.m. OK GNU C++17 (64) TESTS 59 514 547532800
198011340 Peacalm E March 18, 2023, 7:11 p.m. OK GNU C++17 (64) TESTS 60 530 275353600
197997140 LinkWish E March 18, 2023, 5:09 p.m. OK GNU C++17 (64) TESTS 59 530 547532800
198031946 Scarlett_boy E March 19, 2023, 1:28 a.m. OK GNU C++17 (64) TESTS 62 577 81305600
198032811 afuafu E March 19, 2023, 1:50 a.m. OK GNU C++17 (64) TESTS 63 592 270336000
198041211 WYJ_zzzzzzZ E March 19, 2023, 4:40 a.m. OK GNU C++17 (64) TESTS 64 608 285388800
197980928 YaoLingF E March 18, 2023, 3:13 p.m. OK GNU C++17 (64) TESTS 56 638 61747200
197971445 -1e11 E March 18, 2023, 2:15 p.m. OK GNU C++20 (64) TESTS 56 171 4915200
197978019 DimaTomsk E March 18, 2023, 2:57 p.m. OK GNU C++20 (64) TESTS 56 171 19353600
197990830 StarSilk E March 18, 2023, 4:20 p.m. OK GNU C++20 (64) TESTS 56 186 7782400
197983653 Kyou_mo_kawaii E March 18, 2023, 3:29 p.m. OK GNU C++20 (64) TESTS 56 186 16896000
197986897 HaroldVemeno E March 18, 2023, 3:51 p.m. OK GNU C++20 (64) TESTS 56 187 4505600
197980551 DimaTomsk E March 18, 2023, 3:10 p.m. OK GNU C++20 (64) TESTS 56 187 17715200
197979375 DimaTomsk E March 18, 2023, 3:04 p.m. OK GNU C++20 (64) TESTS 56 187 19353600
197979126 DimaTomsk E March 18, 2023, 3:02 p.m. OK GNU C++20 (64) TESTS 56 187 19353600
197977888 DimaTomsk E March 18, 2023, 2:56 p.m. OK GNU C++20 (64) TESTS 56 187 19353600
197977942 DimaTomsk E March 18, 2023, 2:56 p.m. OK GNU C++20 (64) TESTS 56 202 19353600
197971502 dzhi E March 18, 2023, 2:15 p.m. OK Java 11 TESTS 56 2839 111513600
198039684 cc4414 E March 19, 2023, 4:14 a.m. OK Java 8 TESTS 64 1590 242585600
198038293 cc4414 E March 19, 2023, 3:47 a.m. OK Java 8 TESTS 64 2167 269004800
198006980 depurador_ik E March 18, 2023, 6:29 p.m. OK Java 8 TESTS 60 2994 126259200
197978205 elizarov E March 18, 2023, 2:58 p.m. OK Kotlin 1.7 TESTS 56 2308 725504000
198006160 gardengnome E March 18, 2023, 6:22 p.m. OK PyPy 3-64 TESTS 60 889 391884800
198005622 gardengnome E March 18, 2023, 6:17 p.m. OK PyPy 3-64 TESTS 60 889 391987200
198005905 gardengnome E March 18, 2023, 6:20 p.m. OK PyPy 3-64 TESTS 60 936 392499200
198007289 zouyu9631 E March 18, 2023, 6:31 p.m. OK PyPy 3-64 TESTS 60 1170 25600000
197984727 blue_ice_yj E March 18, 2023, 3:36 p.m. OK PyPy 3-64 TESTS 56 1903 262758400
197993254 Red_eye_ E March 18, 2023, 4:39 p.m. OK PyPy 3-64 TESTS 58 1996 56115200
197988231 Little_Sheep_Yawn E March 18, 2023, 4:01 p.m. OK PyPy 3-64 TESTS 56 2105 58675200
198022997 aniketabhiraj2004 E March 18, 2023, 9:37 p.m. OK PyPy 3-64 TESTS 60 2199 46592000
198022909 aniketabhiraj2004 E March 18, 2023, 9:36 p.m. OK PyPy 3-64 TESTS 60 2215 46284800
197977146 Rosiwerk E March 18, 2023, 2:53 p.m. OK PyPy 3-64 TESTS 56 2323 129433600
197994791 liut E March 18, 2023, 4:51 p.m. OK Rust 2021 TESTS 58 2604 860467200
197991293 liut E March 18, 2023, 4:24 p.m. OK Rust 2021 TESTS 57 2886 860467200

remove filters

Back to search problems