OTTFF's Blog
Home
Templates
Contests
Solutions
Notes
笛卡尔树
[CF] E. Special Segments of Permutation - Educational Codeforces Round 64 (Rated for Div. 2)
Solutions
Codeforces
数据结构
笛卡尔树
启发式合并
排列
2200
Med+
2025-02-04
https://codeforces.com/contest/1156/problem/E 题目大意 给出 $n$ 长的排列 $p$。问其中有多少 $l, r$ 子段满足 $p_l + p_r = \max_{i = l}^{r} p_i$。 $3 \le n \le 2 \times 10^5$。$1 \le p_i \le n$ 且不重复。 简要题解 因为涉及到区间最值,想到笛卡尔树。建出最大值为根的笛卡尔树之后相当
…