QOJ.ac

QOJ

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

#7190. 棋盘

الإحصائيات

Bobo 拥有一个 $n$ 行 $m$ 列的棋盘。行从上到下编号为 $1, 2, \dots, n$,列从左到右编号为 $1, 2, \dots, m$。初始时,每个格子被染成黑色或白色。

Bobo 可能会进行 $q$ 次操作。第 $i$ 次操作会改变第 $x_i$ 行第 $y_i$ 列格子的颜色(黑色变白色,或白色变黑色)。他想知道每次操作后连通块的数量。

注意,如果存在格子序列 $c_0 = s, c_1, \dots, c_k = t$,使得对于某些 $k$,格子 $c_{i-1}$ 和 $c_i$ ($1 \le i \le k$) 共享公共边且颜色相同,则称格子 $s$ 和 $t$ 处于同一个连通块中。

输入格式

第一行包含 3 个整数 $n, m, q$ ($1 \le n, m \le 200, 1 \le q \le 2 \times 10^5$)。

接下来的 $n$ 行,每行包含 $m$ 个字符 $b_{i,1}, b_{i,2}, \dots, b_{i,m}$。如果 $b_{i,j} = 1$,则格子 $(i, j)$ 的初始颜色为黑色,否则为白色。

接下来的 $q$ 行,每行包含 2 个整数 $x'_i, y'_i$。实际的操作坐标为 $(x_i, y_i) = (x'_i \oplus o, y'_i \oplus o)$,其中 $o$ 是第 $i$ 次操作前连通块的数量 ($1 \le x_i \le n, 1 \le y_i \le m$)。

注意,“$\oplus$”表示按位异或运算。

输出格式

对于每次操作,输出一个整数,表示连通块的数量。

样例

样例输入 1

2 2 2
01
10
5 5
0 0

样例输出 1

2
1

样例输入 2

1 1 1
0
0 0

样例输出 2

1

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.