Codeforces Round 1097 (Div. 1, Based on Zhili Cup 2026)

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
2223 Codeforces Round 1097 (Div. 1, Based on Zhili Cup 2026) FINISHED False 9000 2418896 May 6, 2026, 6:05 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 25 ) E Zhily and Permutation PROGRAMMING data structures divide and conquer trees

Zhily and Jily enjoy jumping around on a sequence. They move according to some rule, and throughout the process, they draw energy from the interval corresponding to their current positions. They use this energy to restore logical stability. You are given two permutations(^{\text{∗}}) (a) and (b) of length (n). For any open interval (I = (l, r)) where (0 \le l \lt r \le n+1) and (l + 1 \lt r) holds, we define (\operatorname{next}(I) = (\min(i, j), \max(i,j))), where (i = \operatorname*{argmax}\limits_{k \in (l, r)} a_k)(^{\text{†}}); (j = \operatorname*{argmax}\limits_{k \in (l, r)} b_k). You are also given a (0)-indexed non-negative sequence (p) of length (n). The sequence (g(I)) is defined as (g(I) = \begin{cases} 0 & (p_l = 0) \\ 1^{p_l} & (p_l \gt 0) \end{cases})(^{\text{‡}}). The sequence (f(I, k)) is defined as (f(I, k) = \begin{cases} ~ & \text{if } k=0 \text{ or } l+1\ge r \\ g(I) + f(\operatorname{next}(I), k-1) & \text{otherwise} \end{cases})(^{\text{§}}). You need to perform (m) operations: 1 l r k : Output the maximum number of consecutive (1)s in (f((l, r), k)). 2 x y : Assign (y) to (p_x). (^{\text{∗}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). (^{\text{†}})(\operatorname*{argmax}\limits_{k \in (l, r)}) (a_k) denotes the unique index (k) ((l \lt k \lt r)) such that (a_k = \max\limits_{x \in (l, r)} a_x). (^{\text{‡}})Here, (1^m) represents a sequence of length (m) consisting of all (1)s. (^{\text{§}})Here, (~) represents the empty sequence, and the operator (+) between two sequences i

Tutorials

Codeforces Round 1097 (Div. 1, Div2, Based on Zhili Cup 2026) Tutorial

Submissions

No solutions yet.