CF855F Nagini

题目描述

有 $10^5$ 个集合,编号从 $1$ 到 $10^5$。每一个集合内初始没有元素。你需要支持两个操作: `1 l r k`:在编号在 $[l,r)$ 的集合中加入元素 $k$($1 \le l < r \leq 10^5 , k \in [-10^9,0) \cup (0 , 10^9]$)。 `2 l r`:询问编号在 $[l,r)$ 内的集合的权值和($1 \le l < r \leq 10^5$)。 一个集合的权值定义为:如果集合中同时存在 $>0$ 的元素和 $0$ 的元素和最大的 $

输入格式

第一行一个正整数 $q\ (1 \leq q \leq 5 \times 10^4)$ 表示操作数。 接下来 $q$ 行每行一个操作。

输出格式

对于每一个 $2$ 操作输出一行表示答案。

说明/提示

In the first sample case, the danger value for $ x $ -coordinates $ 1 $ is $ 0 $ as there is no $ y_{2} $ satisfying the above condition for $ x=1 $ . Danger values for $ x $ -coordinates $ 2 $ and $ 3 $ is $ 10+|-7|=17 $ . Danger values for $ x $ -coordinates $ 4 $ to $ 9 $ is again $ 0 $ as there is no $ y_{2} $ satisfying the above condition for these coordinates. Thus, total danger value is $ 17+17=34 $ .