QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 2048 MB Total points: 100

#5724. 闪耀吧,小像素,闪耀吧

Statistics

LCD 面板由像素网格组成,水平和垂直方向的间距均为 1 alu(“任意长度单位”)。导线沿每一行和每一列铺设,并在像素处相交。导线编号从 1 开始,向上递增至面板相关的最大值。编号为 1 的垂直导线位于面板左边缘,编号为 1 的水平导线位于面板底边缘。

当电流同时流经穿过某个像素的垂直导线和水平导线时,该像素会被激活并变暗。

在一段时间内,我们将向选定的导线发送电流脉冲。电流以每 atu(“任意时间单位”)1 alu 的速度沿导线流动。脉冲本身的长度以 atu 为单位。当电流同时流经两条相交导线时,像素被激活。如果一条导线上的脉冲前沿到达交点的时间,与另一条导线上的脉冲后沿离开该交点的时间完全相同,则该像素不会被激活。

所有垂直导线上的脉冲均从网格底部开始。所有水平导线上的脉冲均从网格左侧开始。每条导线上最多只会有一个脉冲经过。

给定发送电流脉冲的计划,请确定当所有脉冲都离开网格的顶部和右侧时,总共有多少个像素被激活。

输入格式

第一行包含一个整数 $n$,表示电流脉冲的数量,其中 $1 \le n \le 200\,000$。

接下来 $n$ 行,每行描述一个脉冲。每行包含四个由空格分隔的元素:

  • 一个字符,为 'h' 或 'v',表示脉冲的水平或垂直方向。
  • 一个整数 $t$($1 \le t \le 200\,000$),表示脉冲的开始时间。开始时间定义为垂直 [水平] 脉冲的前沿穿过水平 [垂直] 1 号导线的时刻。
  • 一个整数 $m$($1 \le m \le 200\,000$),表示脉冲的长度。
  • 一个整数 $a$($1 \le a \le 100\,000$),表示脉冲沿其传播的导线编号(水平或垂直)。

输出格式

在一行中输出当最后一个电流脉冲离开网格时,已被激活的像素总数。

样例

样例输入 1

4
h 1 4 1
v 2 4 2
h 10 2 2
v 11 2 3

样例输出 1

2

样例输入 2

4
h 1 10 1
h 5 10 2
v 1 10 1
v 5 10 3

样例输出 2

4

样例输入 3

7
v 1 3 1
v 1 15 2
h 4 5 1
h 5 5 2
h 6 5 3
h 7 5 4
h 8 5 5

样例输出 3

5

Figure 1. LCD 面板像素网格示意图

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.