QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#18674. 蒲公英

统计

在东西方向无限延伸的UCPC道路上,以$1$的间隔放置了无限多的花盆,建造了一个蒲公英花园。所有花盆都标有整数编号,以$0$号花盆为基准,向东$k$距离的花盆编号为$k$,向西$k$距离的花盆编号为$-k$。每个花盆最多只能生长一朵蒲公英。

蒲公英在刮风时,会向该方向$1$距离处的花盆播撒种子。无论是种植还是被风吹落花盆的蒲公英种子,如果该花盆中没有其他蒲公英,就会迅速生长,到第二天就能播撒种子。每朵蒲公英的种子非常多,不会耗尽。

时雨打算用机器人观察蒲公英花园$N$天。机器人观察期间每天输入一条命令并执行。机器人可以执行的命令种类如下:

  • L:向西刮风。对于所有整数$x$,如果$x$号花盆有蒲公英且$(x-1)$号花盆没有蒲公英,则第二天$(x-1)$号花盆会长出新的蒲公英。
  • R:向东刮风。对于所有整数$x$,如果$x$号花盆有蒲公英且$(x+1)$号花盆没有蒲公英,则第二天$(x+1)$号花盆会长出新的蒲公英。
  • C x:在$x$号花盆种植蒲公英种子。如果$x$号花盆没有蒲公英,则第二天会长出新的蒲公英。($-10^9 \le x \le 10^9$;$x$是整数)
  • Q:记录当前有蒲公英的花盆数量。

在开始观察花园之前,只有$0$号花盆种有一朵蒲公英。给定时雨在$N$天期间请求机器人执行的命令列表,请编写一个程序执行这些命令。

输入格式

第一行给出命令的数量$N$。($1 \le N \le 200\,000$)

接下来$N$行,每行给出一个命令。其中第$i$个命令表示机器人在第$i$天需要处理的命令。($1 \le i \le N$)

命令中至少有一个Q

输出格式

对于每个给出Q命令的日子,按时间顺序每行输出该天有蒲公英的花盆数量。

样例

输入样例 1

13
L
C 4
L
Q
C 2
Q
R
C 7
R
Q
R
R
Q

输出样例 1

5
6
11
13

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.