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 |
|---|---|---|---|---|---|---|
| 1863 | Pinely Round 2 (Div. 1 + Div. 2) | FINISHED | False | 10800 | 82999523 | Aug. 30, 2023, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 112 ) | H | Goldberg Machine 3 | PROGRAMMING | dp trees |
There is a complete rooted binary tree, that is, a rooted tree in which each vertex has either (0) or (2) children. The root of the tree is vertex (1). A node without children is called a leaf . Each leaf has a hunger value , we denote the hunger value of leaf (v) by (h_v). Each inner vertex of the tree has a selector pointing to one of the children of the vertex. This tree accepts cookies. Before launching the process you can choose the initial state of each selector individually. The process is as follows: Initially there are no cookies in vertices. You insert cookies into the root one by one. As long as the cookie is not in a leaf, it falls to the child defined by the selector in the current vertex. This selector then changes its state to the opposite one, i. e. it starts pointing to the other child of the vertex. You stop inserting cookies when each leaf (v) has at least (h_v) cookies in it. In this case, we say that the tree is filled up. You have (q) queries. Each query changes the value of (h_v) for some leaf (v). You need to print (q + 1) numbers, the (i)-th of them being the minimum number of cookies required to fill up the machine after ((i - 1)) updates if you can pick any initial state for every selector. Since these numbers may be very large, print the answers modulo (998\,244\,353). Please note that you can choose the initial state of all selectors independently between queries. However, the queries themselves are not independent: when answering the (i)-th query, you should also consider the effect of queries (1, 2, \ldots, i - 1). The first line contains a single integer (n) ((1\le n < 200\,000)) — the number of vertices in the tree. The second line contains (n - 1) integers (p_2, p_3, \ldots, p_n) ((1\le p_i < i)), meaning that the parent of vertex (i) is (p_i). The third line contains (n) integers (h_1, h_2, \ldots, h_n) ($$$0\le h_i\le 10^9 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 221221722 | PolymathFaisal | H | Aug. 31, 2023, 5:12 a.m. | OK | GNU C++17 | TESTS | 33 | 1107 | 409600000 | ||
| 221188380 | QAQAutoMaton | H | Aug. 30, 2023, 7:02 p.m. | OK | GNU C++17 (64) | TESTS | 33 | 998 | 699699200 | ||
| 221187887 | amiya | H | Aug. 30, 2023, 6:56 p.m. | OK | GNU C++17 (64) | TESTS | 33 | 1824 | 101888000 | ||
| 221214363 | jiangly | H | Aug. 31, 2023, 3:09 a.m. | OK | GNU C++20 (64) | TESTS | 33 | 2947 | 58572800 | ||
| 221218426 | BuddhaBarFans | H | Aug. 31, 2023, 4:16 a.m. | OK | GNU C++20 (64) | TESTS | 33 | 6193 | 712499200 | ||
| 221182970 | jiangly | H | Aug. 30, 2023, 6:15 p.m. | OK | GNU C++20 (64) | TESTS | 33 | 6676 | 712499200 |
Back to search problems