QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#3743. 网格

統計

Bobo 有 $n \times m$ 个点,排列成一个 $n$ 行 $m$ 列的矩阵。第 $i$ 行第 $j$ 列的交点标记为 $(i, j)$。 他将执行 $q$ 次以下两种操作:

  1. 给定参数 $a, b$,在所有满足 $a \leq i \leq b$ 且 $1 \leq j < m$ 的点 $(i, j)$ 和 $(i, j + 1)$ 之间添加边。
  2. 给定参数 $a, b$,在所有满足 $1 \leq i < n$ 且 $a \leq j \leq b$ 的点 $(i, j)$ 和 $(i + 1, j)$ 之间添加边。

Bobo 想知道每次操作后连通分量的数量。

输入格式

输入包含多组测试数据,以文件结束符(EOF)结束。

每个测试数据的第一行包含三个整数 $n, m$ 和 $q$。

接下来的 $q$ 行中,第 $i$ 行包含三个整数 $t_i, a_i$ 和 $b_i$,其中 $t_i$ 表示操作类型,$a_i, b_i$ 为对应的参数。

输出格式

对于每组测试数据,输出 $q$ 个整数,表示每次操作后连通分量的数量。

样例

样例输入 1

2 3 3
2 1 1
2 3 3
1 1 1
1000000000 1000000000 1
1 1 2

样例输出 1

5
4
2
999999998000000002

数据范围

  • $1 \leq n, m \leq 10^9$
  • $1 \leq q \leq 10^5$
  • $t_i \in \{1, 2\}$
  • 若 $t_i = 1$,则 $1 \leq a_i \leq b_i \leq n$。若 $t_i = 2$,则 $1 \leq a_i \leq b_i \leq m$。
  • 所有测试数据的 $q$ 之和不超过 $5 \times 10^5$。

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.