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.
Problems
This is the hard version of the problem. The difference between the two versions is the definition of deterministic max-heap, time limit, and constraints on (n) and (t). You can make hacks only if both versions of the problem are solved. Consider a perfect binary tree with size (2^n - 1), with nodes numbered from (1) to (2^n-1) and rooted at (1). For each vertex (v) ((1 \le v \le 2^{n - 1} - 1)), vertex (2v) is its left child and vertex (2v + 1) is its right child. Each node (v) also has a value (a_v) assigned to it. Define the operation (\mathrm{pop}) as follows: initialize variable (v) as (1); repeat the following process until vertex (v) is a leaf (i.e. until (2^{n - 1} \le v \le 2^n - 1)); among the children of (v), choose the one with the larger value on it and denote such vertex as (x); if the values on them are equal (i.e. (a_{2v} = a_{2v + 1})), you can choose any of them; assign (a_x) to (a_v) (i.e. (a_v := a_x)); assign (x) to (v) (i.e. (v := x)); among the children of (v), choose the one with the larger value on it and denote such vertex as (x); if the values on them are equal (i.e. (a_{2v} = a_{2v + 1})), you can choose any of them; assign (a_x) to (a_v) (i.e. (a_v := a_x)); assign (x) to (v) (i.e. (v := x)); assign (-1) to (a_v) (i.e. (a_v := -1)). Then we say the (\mathrm{pop}) operation is deterministic if there is a unique way to do such operation. In other words, (a_{2v} \neq a_{2v + 1}) would hold whenever choosing between them. A binary tree is called a max-heap if for every vertex (v) ((1 \le v \le 2^{n - 1} - 1)), both (a_v \ge a_{2v}) and (a_v \ge a_{2v + 1}) hold. A max-heap is deterministic if the (\mathrm{pop}) operation is deterministic to the heap when we do it for the first and the second time . Initially, (a_v := 0) for every vertex (v) ($$$1 |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
277464168 |
luckyzfy |
E2 |
Aug. 21, 2024, 3:23 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
32 |
655 |
229990400 |
|
|
|
277428958 |
little_vegetable |
E2 |
Aug. 20, 2024, 6:18 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
32 |
1671 |
430182400 |
|
|
|
277445581 |
Kilani |
E2 |
Aug. 20, 2024, 9:23 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
32 |
515 |
108441600 |
|
|
|
277473732 |
clyzszh |
E2 |
Aug. 21, 2024, 5:30 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
32 |
843 |
0 |
|
|
|
277423285 |
nguyentunglam |
E2 |
Aug. 20, 2024, 5:46 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
32 |
1061 |
107417600 |
|
|
|
277430942 |
alvingogo |
E2 |
Aug. 20, 2024, 6:32 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
32 |
1109 |
430284800 |
|
|
|
277413177 |
lichenghan |
E2 |
Aug. 20, 2024, 4:25 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
32 |
1671 |
12288000 |
|
|
|
277461763 |
birdfox |
E2 |
Aug. 21, 2024, 2:50 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
32 |
1890 |
3481600 |
|
|
|
277465310 |
marvinthang |
E2 |
Aug. 21, 2024, 3:37 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
233 |
2252800 |
|
|
|
277457405 |
marvinthang |
E2 |
Aug. 21, 2024, 1:49 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
280 |
2252800 |
|
|
|
277423796 |
marvinthang |
E2 |
Aug. 20, 2024, 5:48 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
280 |
2252800 |
|
|
|
277427106 |
neal |
E2 |
Aug. 20, 2024, 6:06 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
342 |
102400 |
|
|
|
277459379 |
BurnedChicken |
E2 |
Aug. 21, 2024, 2:19 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
453 |
3891200 |
|
|
|
277424963 |
marvinthang |
E2 |
Aug. 20, 2024, 5:54 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
453 |
239104000 |
|
|
|
277425727 |
potato167 |
E2 |
Aug. 20, 2024, 5:58 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
484 |
0 |
|
|
|
277415968 |
MatrixGroup |
E2 |
Aug. 20, 2024, 4:30 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
640 |
17203200 |
|
|
|
277425077 |
luka_modric2003 |
E2 |
Aug. 20, 2024, 5:55 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
640 |
430182400 |
|
|
|
277472772 |
yanold |
E2 |
Aug. 21, 2024, 5:17 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
32 |
764 |
218214400 |
|
|
remove filters
Back to search problems