Type: Default 1000ms 256MiB

A. 切木条

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

A. 切木条

题目描述

给定一个长度为 LL 的木条,有 LL[1,L][1,L],每段长度为 11,一开始连在一起。

依次处理 QQ 个询问。

ii 次询问,给定两个数 cic_ixix_i,如果 ci=1c_i = 1,将第 xx 段所在的连续木条 [l,r][l,r] 切分为两段:[l,x][l,x][x+1,r][x+1,r]; 如果 ci=2c_i = 2,输出第 xx 段所在连续木条的长度。


输入格式

L Q
c_1 x_1
c_2 x_2
⋮
c_Q x_Q

输出格式

对于每一个 2 类询问,输出一行答案。


样例

输入样例 #1

5 3
2 2
1 3
2 2

输出样例 #1

5
3

输入样例 #2

5 3
1 2
1 4
2 3

输出样例 #2

2

输入样例 #3

100 10
1 31
2 41
1 59
2 26
1 53
2 58
1 97
2 93
1 23
2 84

输出样例 #3

69
31
6
38
38

数据范围与提示

  • 1L1091 \le L \le 10^9
  • 1Q2×1051 \le Q \le 2 \times 10^5
  • ci=1,2 (1iQ)c_i = 1, 2\ (1 \le i \le Q)
  • 1xiL1 (1iQ)1 \le x_i \le L - 1\ (1 \le i \le Q)

20260319

Not Claimed
Status
Done
Problem
7
Open Since
2026-3-18 0:00
Deadline
2026-3-31 23:59
Extension
24 hour(s)