AT_abc461_e.E-liter

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is an N×NN \times N grid. Initially, all cells are painted white.

Process QQ queries in the given order. Each query is one of the following:

  • Type 11: An integer RR is given. Paint all cells in the RR-th row from the top of the grid black.
  • Type 22: An integer CC is given. Paint all cells in the CC-th column from the left of the grid white.

After processing each query, output the number of black cells in the grid at that point.

有一个 N×NN \times N 的网格。初始时,所有格子均为白色。

按给定顺序处理 QQ 个查询。每个查询为以下两种类型之一:

  • 类型 11:给出一个整数 RR,将网格中从上往下数第 RR 行的所有格子涂成黑色。
  • 类型 22:给出一个整数 CC,将网格中从左往右数第 CC 列的所有格子涂成白色。

在每次查询处理完毕后,输出此时网格中黑色格子的数量。

输入格式

The input is given from Standard Input in the following format:

NN QQ
query1\text{query}_1
query2\text{query}_2
⋮\vdots
queryQ\text{query}_Q

Here, queryi\text{query}_i is the ii-th query, given in one of the following formats.

Type 11:

1 RR

Type 22:

2 CC

输入从标准输入中以如下格式给出:

NN QQ
query1\text{query}_1
query2\text{query}_2
⋮\vdots
queryQ\text{query}_Q

其中,queryi\text{query}_i 表示第 ii 个查询,其格式为以下两种之一。

类型 11:

1 RR

类型 22:

2 CC

输出格式

Output QQ lines. The ii-th line should contain the number of black cells in the grid at the time the ii-th query has been processed.

输出 QQ 行。第 ii 行应包含处理完第 ii 个查询时网格中黑色格子的数量。

输入输出样例

  • 输入#1

    3 4
    1 1
    1 3
    2 2
    1 1

    输出#1

    3
    6
    4
    5 ...    ###    ###    #.#    ###
    ... -> ... -> ... -> ... -> ...
    ...    ...    ###    #.#    #.#
  • 输入#2

    300000 1
    2 300000

    输出#2

    0

说明/提示

Sample 1 Explanation:
The changes in the grid are shown using characters. . represents a white cell, and # represents a black cell.

Sample 2 Explanation:
Beware of overflow in larger cases.

Constraints

  • 1≤N,Q≤3×1051 \leq N, Q \leq 3 \times 10^5
  • For type 11 queries, 1≤R≤N1 \leq R \leq N.
  • For type 22 queries, 1≤C≤N1 \leq C \leq N.
  • All input values are integers.

样例 1 解释:
网格的变化使用字符表示。. 表示白色格子,# 表示黑色格子。

样例 2 解释:
注意在较大规模情况下可能出现整数溢出。

限制条件

  • 1≤N,Q≤3×1051 \leq N, Q \leq 3 \times 10^5
  • 对于类型 11 的查询,满足 1≤R≤N1 \leq R \leq N。
  • 对于类型 22 的查询,满足 1≤C≤N1 \leq C \leq N。
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页