2026 ICPC Asia Pacific Championship - Online Mirror (Unrated, Online Mirror, ICPC Rules, Teams Preferred)

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
2206 2026 ICPC Asia Pacific Championship - Online Mirror (Unrated, Online Mirror, ICPC Rules, Teams Preferred) FINISHED False 18000 3471323 March 8, 2026, 1:45 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 216 ) D Christmas Tree Un-decoration PROGRAMMING data structures dp trees

Last Christmas, you had a lovely Christmas tree with (n) vertices, numbered from (1) to (n) and rooted at vertex (1). For each (i) ((2 \le i \le n)), vertex (p_i) is the parent of vertex (i). The tree is decorated beautifully with (a_i) ornaments on vertex (i) ((1 \le i \le n)). However, it has already been a few months since Christmas, and it is time to take down all the ornaments and put your tree away until next year. Since this process is tedious, you have decided to make it more fun by using only the following operation, which you can perform zero or more times: Choose a vertex (u). For each vertex (v) on the unique simple path from vertex (1) to vertex (u) (inclusive), remove exactly one ornament from (v) if there is any left. While you are still determining the minimum number of operations needed, your little child modifies the number of ornaments on the tree. More precisely, your child makes (q) changes. In the (j)-th change, the number of ornaments on vertex (u_j) is modified to (x_j) ((1 \le j \le q)). Note that these changes are persistent; the effect of each change carries over to subsequent changes. Note that you do not actually perform any operations on the tree. For the initial configuration and after each change, your task is to determine the minimum number of operations needed to remove all the ornaments from the tree at each moment. The first line of input contains one integer (t) ((1 \le t \le 10\,000)) representing the number of test cases. After that, (t) test cases follow. Each of them is presented as follows. The first line of each test case contains two integers (n) and (q) ((2 \le n \le 200\,000); (1 \le q \le 200\,000)). The second line contains (n-1) integers (p_2, p_3, \ldots, p_n) ((1 \le p_i \lt i) for all (2 \le i \le n)). The third line contains (n) integers (a_1, a_2, \ldots, a_n) ($$$1 \le

Tutorials

Tutorial (PDF)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
365799713 cse.scholarx D March 8, 2026, 4:15 a.m. OK C++17 (GCC 7-32) TESTS 54 656 16486400
365808847 AK589 LucZha D March 8, 2026, 6:14 a.m. OK C++17 (GCC 7-32) TESTS 54 687 31948800
365801845 mo0dman Arsentii OneCyborg D March 8, 2026, 4:51 a.m. OK C++17 (GCC 7-32) TESTS 54 718 24780800
365851917 didxga D March 8, 2026, 1:29 p.m. OK C++17 (GCC 7-32) TESTS 54 843 32358400
365803828 hiteshjakhar__29 D March 8, 2026, 5:18 a.m. OK C++17 (GCC 7-32) TESTS 54 937 29184000
365801217 mtsd potato167 toam D March 8, 2026, 4:41 a.m. OK C++17 (GCC 7-32) TESTS 54 1000 31846400
365804722 _el3bd_ D March 8, 2026, 5:27 a.m. OK C++17 (GCC 7-32) TESTS 54 1140 41164800
365805007 zoryn D March 8, 2026, 5:31 a.m. OK C++17 (GCC 7-32) TESTS 54 1578 39628800
365802007 Amoo_Safar D March 8, 2026, 4:54 a.m. OK C++17 (GCC 7-32) TESTS 54 1578 78438400
365806737 gs12117 D March 8, 2026, 5:51 a.m. OK C++17 (GCC 7-32) TESTS 54 1703 22118400
365802465 khoa20100 D March 8, 2026, 5:01 a.m. OK C++20 (GCC 13-64) TESTS 54 453 20480000
365831992 cho57020 D March 8, 2026, 10:10 a.m. OK C++20 (GCC 13-64) TESTS 54 468 36249600
365813349 pyqjw1 D March 8, 2026, 6:59 a.m. OK C++20 (GCC 13-64) TESTS 54 515 30617600
365798620 prantogoswamee D March 8, 2026, 3:56 a.m. OK C++20 (GCC 13-64) TESTS 54 687 32563200
365808244 nekshavs D March 8, 2026, 6:07 a.m. OK C++20 (GCC 13-64) TESTS 54 718 51097600
365807227 Rubikun D March 8, 2026, 5:56 a.m. OK C++20 (GCC 13-64) TESTS 54 750 46489600
365800585 VHPro Kuroni fextivity D March 8, 2026, 4:30 a.m. OK C++20 (GCC 13-64) TESTS 54 781 52019200
365806206 nekshavs D March 8, 2026, 5:45 a.m. OK C++20 (GCC 13-64) TESTS 54 859 50995200
365798180 duckagainduck nguyentunglam ItsJerr D March 8, 2026, 3:48 a.m. OK C++20 (GCC 13-64) TESTS 54 890 52633600
365795808 dXqwq Xun_Xiaoyao crazy_sea D March 8, 2026, 3:06 a.m. OK C++20 (GCC 13-64) TESTS 54 968 140800000
365805716 Hridoy1013 D March 8, 2026, 5:39 a.m. OK C++23 (GCC 14-64, msys2) TESTS 54 359 35225600
365927303 golomb D March 9, 2026, 12:09 a.m. OK C++23 (GCC 14-64, msys2) TESTS 54 406 39219200
365802275 men.d D March 8, 2026, 4:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 54 406 41984000
365806348 physics0523 someone__ tatyam D March 8, 2026, 5:47 a.m. OK C++23 (GCC 14-64, msys2) TESTS 54 437 40857600
365925199 czjxyz zacharychao kevin D March 8, 2026, 11:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 54 453 46284800
365795610 risujiroh Nyaan D March 8, 2026, 3:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 54 453 50585600
365798922 0.1w33hw3 maomao90 __baozii__ D March 8, 2026, 4:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 54 468 61644800
365915615 dreamoon_love_AA D March 8, 2026, 8:19 p.m. OK C++23 (GCC 14-64, msys2) TESTS 54 484 29900800
365839408 KumaTachiRen D March 8, 2026, 11:24 a.m. OK C++23 (GCC 14-64, msys2) TESTS 54 515 52326400
365913755 mohamedtarekfayez005 D March 8, 2026, 7:55 p.m. OK C++23 (GCC 14-64, msys2) TESTS 54 531 23552000
365804139 mikelou D March 8, 2026, 5:21 a.m. OK PyPy 3-64 TESTS 54 1062 132710400
365795555 Chayanine D March 8, 2026, 3:01 a.m. OK PyPy 3-64 TESTS 54 1406 155750400
365813648 sansen D March 8, 2026, 7:02 a.m. OK Rust 2021 TESTS 54 1187 80486400
365816875 sansen D March 8, 2026, 7:37 a.m. OK Rust 2021 TESTS 54 1265 77312000
365812497 sansen D March 8, 2026, 6:51 a.m. OK Rust 2021 TESTS 54 1281 80588800
365816989 sansen D March 8, 2026, 7:38 a.m. OK Rust 2021 TESTS 54 2265 77209600
365800383 sansen D March 8, 2026, 4:27 a.m. OK Rust 2021 TESTS 54 2640 80588800
365812405 sansen D March 8, 2026, 6:50 a.m. OK Rust 2021 TESTS 54 2687 80588800
365856261 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856606 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856575 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856562 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856493 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856420 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856358 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856339 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856285 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856503 D March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0

remove filters

Back to search problems