QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#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.