Codeforces Round 1077 (Div. 1)

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
2187 Codeforces Round 1077 (Div. 1) FINISHED False 10800 6708323 Jan. 29, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 90 ) G Many Cartesian Trees PROGRAMMING greedy

Consider an array (a) consisting of (n) distinct integers. The Cartesian Tree of (a) is defined as a unique binary tree(^{\text{∗}}) that satisfies the following conditions: The tree consists of (n) vertices labeled from (1) to (n); For all pairs of vertices ((i,j)) such that (i) is a parent(^{\text{†}}) of (j), (a_i > a_j); For any vertex (i), all vertices in the left subtree(^{\text{‡}}) of (i) have labels less than (i); For any vertex (i), all vertices in the right subtree of (i) have labels greater than (i). Denote (r(a)) as the root of the Cartesian Tree, and (f_a(i)) as the parent of (i) in the Cartesian Tree. Define (E_a=\{(i,f_a(i)) \mid 1 \le i \le n, i \ne r(a)\}). Consider a permutation(^{\text{§}}) (q) of length (n). We define a series of arrays (p_1,p_2,\ldots,p_n) as follows: (p_1=q); For each (2 \le i \le n), (p_i) is obtained by incrementing the minimum element in (p_{i-1}) by (n). It can be shown that all elements in (p_i) are distinct. You are now given (n) and (S=\bigcup\limits_{i=1}^n E_{p_i}). To minimize input, (S) will be given in the form of a (n \times n) binary matrix (s). Denote (s_{i,j}) as the (j)-th character of the (i)-th row. (s_{i,j}=1) if and only if ((i,j) \in S). Please find any permutation (q) such that (S) can be obtained by the process above. It is guaranteed that the tests are generated to ensure a valid (q) always exists. (^{\text{∗}})A binary tree is a rooted tree, in which each node has no more than (2) children, referred to as the left child and the right child. (^{\text{†}})The parent of vertex (v) is the first vertex on the simple path from (v) to the root. The root has no parent. (^{\text{‡}})A subtree of vertex (v) is the subgraph of (v), all its descendants, and all the edges between them. $$$^{\

Tutorials

Codeforces Round 1077 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
360651944 Legend_of_Bangladesh G Jan. 30, 2026, 2:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 19 125 7884800
360634813 ecnerwala G Jan. 29, 2026, 8:22 p.m. OK C++23 (GCC 14-64, msys2) TESTS 19 125 7884800

remove filters

Back to search problems