CF1093E Intersection of Permutations
题目描述
给定整数 $n$ 和两个 $1,\dots,n$ 的排列 $a,b$。
$m$ 个操作,操作有两种:
- $1\ l_a\ r_a\ l_b\ r_b$,设 $a$ 的 $[l_a;r_a]$ 区间内的元素集合为 $S_a$,设 $b$ 的 $[l_b;r_b]$ 区间内的元素集合为 $S_b$,求 $\lvert S_a \bigcap S_b \rvert$。
- $2\ x\ y$,交换 $b$ 的第 $x$ 位与第 $y$ 位。
$1 \le n,m \le 2 \cdot 10^5$
输入格式
无
输出格式
无
说明/提示
Consider the first query of the first example. Values on positions $ [1; 2] $ of $ a $ are $ [5, 1] $ and values on positions $ [4; 5] $ of $ b $ are $ [1, 4] $ . Only value $ 1 $ appears in both segments.
After the first swap (the second query) permutation $ b $ becomes $ [2, 1, 3, 5, 4, 6] $ .
After the second swap (the sixth query) permutation $ b $ becomes $ [5, 1, 3, 2, 4, 6] $ .