Universal Cup Judging System

Universal Cup

Süre Sınırı: 5 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

图 1:Jasper 日程中平常的一天。

Jasper 的日程非常满。他当前有 $n$ 个预约,其中第 $i$ 个预约发生在开区间 $(x_i, y_i)$ 内。由于其中许多预约是在线进行的,Jasper 可以同时参加多个预约。为了使他的规划不那么混乱,Jasper 对他当前的日程执行 $q$ 次操作:

  • split $t$:Jasper 在时间 $t$ 稍作休息。所有满足 $x < t < y$ 的预约 $(x, y)$ 都会被拆分为两个新预约:$(x, t)$ 和 $(t, y)$。
  • skip $t$:Jasper 决定跳过在时间 $t$ 正在进行的所有预约。因此,每个满足 $x < t < y$ 的预约 $(x, y)$ 都会被完全移除。

请注意,这些操作是持久生效的。

预约 $(x, y)$ 的时长定义为 $y - x$。请在每次操作后,计算 Jasper 日程中仍保留的所有预约的时长总和。输入使用了“prevans xor”编码(参见输入格式与输出格式)。

输入格式

第一行包含两个整数 $n$ 和 $q$($1 \le n, q \le 3 \cdot 10^5$),分别表示初始预约的数量和操作的数量。

接下来的 $n$ 行(每个预约一行),每行包含两个整数 $x_i$ 和 $y_i$($0 \le x_i < y_i \le 10^6$),表示第 $i$ 个预约的开始时间和结束时间。

最后 $q$ 行描述这些操作。第 $i$ 行包含一个字符串 $s_i$ 和一个整数 $t'_i$,其中 $s_i$ 为 "split"(表示拆分操作)或 "skip"(表示跳过操作)。该操作的时间 $t_i$ 等于 $t_i = t'_i \oplus \text{ans}_{i-1}$,即输入的 $t'_i$ 与上一次操作后的答案 $\text{ans}_{i-1}$ 的按位异或。数值 $\text{ans}_0$ 为初始 $n$ 个预约的时长之和。

保证对于所有 $i$,均有 $0 \le t_i \le 10^6$,且所有的 $t_i$ 互不相同。

输出格式

输出 $q+1$ 个整数 $\text{ans}_0, \text{ans}_1, \dots, \text{ans}_q$,其中 $\text{ans}_i$ 表示前 $i$ 次操作后的时长总和。数值 $\text{ans}_0$ 为初始 $n$ 个预约的时长之和。

样例

输入格式 1

3 3
1 10
2 5
4 13
split 22
skip 17
skip 0

输出格式 1

21
21
12
3

说明

在样例中,最初有 3 个预约($(1, 10)$、$(2, 5)$ 和 $(4, 13)$),总时长为 $21$。在第一次操作($t = 22 \oplus 21 = 3$)后,变为 5 个预约($(1, 3)$、$(3, 10)$、$(2, 3)$、$(3, 5)$ 和 $(4, 13)$),总时长仍为 $21$。第二次操作($t = 17 \oplus 21 = 4$)将移除预约 $(3, 10)$ 和 $(3, 5)$,使得总时长变为 $12$。第三次操作($t = 0 \oplus 12 = 12$)将移除预约 $(4, 13)$,最终剩余的总时长为 $3$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.