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
( 302 ) B Subtree Removal Game PROGRAMMING games

You are given a rooted tree with (n) nodes, numbered from (1) to (n), rooted at node (1). For each node (i) ((2 \le i \le n)), its parent is node (p_i). For each node (i), if it is a leaf (a node having no children), the integer (i) is written on it. Otherwise, nothing is written. Node (u) is a descendant of node (v) if (u = v), or (u) is not the root and the parent of (u) is a descendant of (v). Now, you and your friend play a game on this tree, taking turns alternately: You move first, then your friend, and so on. On each turn, the current player must choose a node (v) and then remove the entire subtree of (v) (i.e., all descendants of (v), including (v) itself). The move is allowed only if, after the removal, at least one node with an integer written on it remains in the tree. The game ends when no further moves are possible. At that point, exactly one node with an integer written on it remains; the score of the game is the integer on that node. You aim to minimize the score, while your friend aims to maximize it. Assuming you and your friend play optimally, determine the score of the game. The first line of input contains an integer (n) ((2 \le n \le 500\,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)). Output the score of the game assuming you and your friend play optimally. Explanation for the sample input/output #1 The given tree is illustrated in Figure B.1 (a). The only optimal moves for both players are as follows: You choose node (5). Then nodes (5), (6), and (7) are removed (Figure B.1 (b)). Your friend chooses node (3). Then only node (3) is removed (Figure B.1 (c)). You cannot make any moves, and the game ends. Explanation for the sample input/output #2 The given tree is illustrated in Figure B.2. One of the optimal moves for you is to choose node (2)

Tutorials

Tutorial (PDF)

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
365803296 _el3bd_ B March 8, 2026, 5:11 a.m. OK C++17 (GCC 7-32) TESTS 35 203 2252800
365796080 gs12117 B March 8, 2026, 3:11 a.m. OK C++17 (GCC 7-32) TESTS 35 250 6041600
365797997 cse.scholarx B March 8, 2026, 3:45 a.m. OK C++17 (GCC 7-32) TESTS 35 281 14438400
365799717 mo0dman Arsentii OneCyborg B March 8, 2026, 4:15 a.m. OK C++17 (GCC 7-32) TESTS 35 296 18432000
365799921 pinerush pinterestlover123 B March 8, 2026, 4:19 a.m. OK C++17 (GCC 7-32) TESTS 35 312 14540800
365810587 AK589 LucZha B March 8, 2026, 6:33 a.m. OK C++17 (GCC 7-32) TESTS 35 390 14540800
365908956 HanaYukii B March 8, 2026, 6:56 p.m. OK C++17 (GCC 7-32) TESTS 35 421 14643200
365802422 hiteshjakhar__29 B March 8, 2026, 5:01 a.m. OK C++17 (GCC 7-32) TESTS 35 437 12492800
365795529 lh3k liuhangxin sh1ziku B March 8, 2026, 3:01 a.m. OK C++17 (GCC 7-32) TESTS 35 843 34508800
365817613 islingr B March 8, 2026, 7:44 a.m. OK C++20 (GCC 13-64) TESTS 35 203 2252800
365810496 BrotherLouie B March 8, 2026, 6:32 a.m. OK C++20 (GCC 13-64) TESTS 35 265 25190400
365845118 lotus_pjl B March 8, 2026, 12:24 p.m. OK C++20 (GCC 13-64) TESTS 35 265 29388800
365798181 prantogoswamee B March 8, 2026, 3:48 a.m. OK C++20 (GCC 13-64) TESTS 35 281 21196800
365811693 pyqjw1 B March 8, 2026, 6:44 a.m. OK C++20 (GCC 13-64) TESTS 35 281 21299200
365800744 khoa20100 B March 8, 2026, 4:33 a.m. OK C++20 (GCC 13-64) TESTS 35 296 98304000
365832345 Rubikun B March 8, 2026, 10:14 a.m. OK C++20 (GCC 13-64) TESTS 35 328 19148800
365793113 MODDI B March 8, 2026, 2:20 a.m. OK C++20 (GCC 13-64) TESTS 35 343 93388800
365799496 mo_onrabbit2 B March 8, 2026, 4:11 a.m. OK C++20 (GCC 13-64) TESTS 35 359 21094400
365792194 dXqwq Xun_Xiaoyao crazy_sea B March 8, 2026, 2:02 a.m. OK C++20 (GCC 13-64) TESTS 35 468 12083200
365796991 Momotaros B March 8, 2026, 3:26 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 140 6553600
365920476 dreamoon_love_AA B March 8, 2026, 9:29 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 140 14233600
365818039 navin_777 B March 8, 2026, 7:49 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 156 6553600
365913657 mohamedtarekfayez005 B March 8, 2026, 7:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 171 409600
365848905 Ibrohim-Shamsiev B March 8, 2026, 1:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 171 409600
365793430 ksun48 ecnerwala B March 8, 2026, 2:26 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 171 409600
365798942 minhnguyenxuan60 Andwerp jlass_ B March 8, 2026, 4:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 171 2252800
365857148 Penguin07 B March 8, 2026, 1:57 p.m. OK C++23 (GCC 14-64, msys2) TESTS 35 187 307200
365800148 deltarune Kaling B March 8, 2026, 4:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 203 4608000
365796646 Msgnh zhibohemain B March 8, 2026, 3:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 35 250 7475200
365923455 golomb B March 8, 2026, 10:29 p.m. OK PyPy 3 TESTS 35 765 46796800
365806015 divine_grace lavanyabani B March 8, 2026, 5:43 a.m. OK PyPy 3-64 TESTS 35 406 72396800
365795479 Chayanine B March 8, 2026, 3 a.m. OK PyPy 3-64 TESTS 35 1359 76697600
365794669 mikelou B March 8, 2026, 2:47 a.m. OK PyPy 3-64 TESTS 35 1531 77209600
365856511 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856461 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856403 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856370 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856369 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856297 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856296 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856290 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856288 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0
365856287 B March 8, 2026, 1:52 p.m. OK Unknown TESTS 0 0 0

remove filters

Back to search problems