Good Bye 2023

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
1916 Good Bye 2023 FINISHED False 7200 72457823 Dec. 30, 2023, 2:50 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2632 ) E Happy Life in University PROGRAMMING brute force data structures dfs and similar dp implementation trees

Egor and his friend Arseniy are finishing school this year and will soon enter university. And since they are very responsible guys, they have started preparing for admission already. First of all, they decided to take care of where they will live for the long four years of study, and after visiting the university's website, they found out that the university dormitory can be represented as a root tree with (n) vertices with the root at vertex (1). In the tree, each vertex represents a recreation with some type of activity (a_i). The friends need to choose (2) recreations (not necessarily different) in which they will settle. The guys are convinced that the more the value of the following function (f(u, v) = diff(u, lca(u, v)) \cdot diff(v, lca(u, v))), the more fun their life will be. Help Egor and Arseniy and find the maximum value of (f(u, v)) among all pairs of recreations! (^{\dagger} diff(u, v)) — the number of different activities listed on the simple path from vertex (u) to vertex (v). (^{\dagger} lca(u, v)) — a vertex (p) such that it is at the maximum distance from the root and is a parent of both vertex (u) and vertex (v). Each test consists of several test cases. The first line contains a single integer (t) ((1 \le t \le 10^5)) — the number of test cases. Then follows the description of the test cases. The first line of each test case contains a single integer (n) ((1 \le n \le 3 \cdot 10^{5})). The second line of each test case contains ({n - 1}) integers (p_2, p_3, \ldots,p_n) ((1 \le p_i \le i - 1)), where (p_i) — the parent of vertex (i). The third line of each test case contains ({n}) integers (a_1, a_2, \ldots,a_n) ((1 \le a_i \le n)), where (a_i) — the number of the activity located at vertex (i). It is guaranteed that the sum of (n) over all test cases does not exceed (3 \cdot 10^5). For each test case, output the maximum

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
239734675 rainboy E Dec. 30, 2023, 9:32 p.m. OK GNU C11 TESTS 32 358 44953600
239750981 forgotmyhandle E Dec. 31, 2023, 4:07 a.m. OK GNU C++14 TESTS 36 295 73625600
239748410 Lsince_yx E Dec. 31, 2023, 3:21 a.m. OK GNU C++14 TESTS 36 311 67481600
239750999 forgotmyhandle E Dec. 31, 2023, 4:08 a.m. OK GNU C++14 TESTS 36 311 73625600
239751213 forgotmyhandle E Dec. 31, 2023, 4:12 a.m. OK GNU C++14 TESTS 36 311 73625600
239746152 scallionsong E Dec. 31, 2023, 2:37 a.m. OK GNU C++14 TESTS 35 327 56627200
239751142 usernameson E Dec. 31, 2023, 4:11 a.m. OK GNU C++14 TESTS 36 342 81920000
239749802 2020wtty E Dec. 31, 2023, 3:46 a.m. OK GNU C++14 TESTS 36 343 40857600
239744497 zyxawa E Dec. 31, 2023, 1:58 a.m. OK GNU C++14 TESTS 34 343 68608000
239747509 2020wtty E Dec. 31, 2023, 3:05 a.m. OK GNU C++14 TESTS 36 358 40857600
239708979 my_name_is_handsome E Dec. 30, 2023, 4:38 p.m. OK GNU C++14 TESTS 32 374 264294400
239736205 lotusblume E Dec. 30, 2023, 10:05 p.m. OK GNU C++17 TESTS 33 170 36556800
239710118 Gabp E Dec. 30, 2023, 4:40 p.m. OK GNU C++17 TESTS 32 217 37376000
239750053 keleita E Dec. 31, 2023, 3:50 a.m. OK GNU C++17 TESTS 36 311 54272000
239713685 414s_boy E Dec. 30, 2023, 4:47 p.m. OK GNU C++17 TESTS 32 311 71270400
239709974 gzchenben E Dec. 30, 2023, 4:40 p.m. OK GNU C++17 TESTS 32 312 40550400
239750008 keleita E Dec. 31, 2023, 3:50 a.m. OK GNU C++17 TESTS 36 312 54272000
239750123 keleita E Dec. 31, 2023, 3:52 a.m. OK GNU C++17 TESTS 36 326 54272000
239714349 antonis.white E Dec. 30, 2023, 4:48 p.m. OK GNU C++17 TESTS 32 327 45568000
239750099 keleita E Dec. 31, 2023, 3:51 a.m. OK GNU C++17 TESTS 36 342 54272000
239708902 scallionsong E Dec. 30, 2023, 4:38 p.m. OK GNU C++17 TESTS 32 343 56729600
239712661 lddlinan E Dec. 30, 2023, 4:46 p.m. OK GNU C++17 (64) TESTS 32 280 69734400
239751935 zjjws E Dec. 31, 2023, 4:26 a.m. OK GNU C++17 (64) TESTS 36 295 104652800
239740362 Lucky-Xiang E Dec. 30, 2023, 11:54 p.m. OK GNU C++17 (64) TESTS 34 326 134656000
239746242 oh_my_shy E Dec. 31, 2023, 2:39 a.m. OK GNU C++17 (64) TESTS 35 343 72089600
239739848 yuan-shen E Dec. 30, 2023, 11:36 p.m. OK GNU C++17 (64) TESTS 34 343 119193600
239733254 udon1206 E Dec. 30, 2023, 9:07 p.m. OK GNU C++17 (64) TESTS 32 358 69734400
239747243 oh_my_shy E Dec. 31, 2023, 3 a.m. OK GNU C++17 (64) TESTS 35 358 72089600
239725679 lunchbox E Dec. 30, 2023, 7:32 p.m. OK GNU C++17 (64) TESTS 32 390 135884800
239745737 luogu_bot4 E Dec. 31, 2023, 2:27 a.m. OK GNU C++17 (64) TESTS 34 404 94924800
239724848 lunchbox E Dec. 30, 2023, 7:27 p.m. OK GNU C++17 (64) TESTS 32 420 131072000
239707511 ashwanth106121023 E Dec. 30, 2023, 4:35 p.m. OK GNU C++20 (64) TESTS 32 217 56422400
239729911 ashwanth106121023 E Dec. 30, 2023, 8:16 p.m. OK GNU C++20 (64) TESTS 32 217 56422400
239741875 Keq1ng E Dec. 31, 2023, 12:42 a.m. OK GNU C++20 (64) TESTS 34 233 83353600
239711665 Theo830 E Dec. 30, 2023, 4:44 p.m. OK GNU C++20 (64) TESTS 32 234 74547200
239725762 Rodionno E Dec. 30, 2023, 7:33 p.m. OK GNU C++20 (64) TESTS 32 249 79360000
239730258 kaiboy E Dec. 30, 2023, 8:21 p.m. OK GNU C++20 (64) TESTS 32 265 61644800
239742545 rui_er E Dec. 31, 2023, 1:02 a.m. OK GNU C++20 (64) TESTS 34 265 73318400
239751374 Athanasy E Dec. 31, 2023, 4:16 a.m. OK GNU C++20 (64) TESTS 36 280 88985600
239709297 LinkWish E Dec. 30, 2023, 4:39 p.m. OK GNU C++20 (64) TESTS 32 296 84172800
239724360 Rodionno E Dec. 30, 2023, 7:24 p.m. OK GNU C++20 (64) TESTS 32 296 113049600
239714355 ilyakor E Dec. 30, 2023, 4:49 p.m. OK MS C++ 2017 TESTS 32 795 50892800
239729069 DavitMarg E Dec. 30, 2023, 8:05 p.m. OK MS C++ 2017 TESTS 32 841 61952000
239733917 PugachAG E Dec. 30, 2023, 9:18 p.m. OK Rust 2021 TESTS 32 592 159027200
239738517 kost E Dec. 30, 2023, 11:09 p.m. OK Rust 2021 TESTS 34 919 150528000

remove filters

Back to search problems