QOJ.ac

QOJ

Time Limit: 1.5 s Memory Limit: 64 MB Total points: 100

#22367. 节日绘画

Statistics

为了展现节日热情,奶牛们想画一幅画!画是由单位方格组成的 $R$ $\times$ $C$ 网格 $(1 \le R \le 50,000; 1 \le C \le 15)$,每格为0或1。行编号 $1,\ldots,R$,列编号 $1,\ldots,C$。

时间紧迫,奶牛向边境以北的邻居求助。在驼鹿 Canmuu 的热心指导下,她们造出整桶泼漆的机器!画初始全0,机器向矩形区域泼颜色0或1。Canmuu 建议执行 $Q$ 次操作 $(1 \le Q \le 10,000)$;操作 $i$ 由五整数 $R1_{i}$、$R2_{i}$、$C1_{i}$、$C2_{i}$、$X_{i}$ $(1 \le R1_i \le R2_i \le R; 1 \le C1_i \le C2_i \le C; 0 \le X_{i} \le 1)$ 构成,将行号从 $R1_{i}$ 到 $R2_{i}$、列号从 $C1_{i}$ 到 $C2_{i}$ 的每个方格(均含端点)涂成 $X_{i}$。

但这样画很容易出错,因此 Canmuu 请你确定每次操作后网格中颜色正确的单位方格数。

内存限制:64 MB

时间限制:1.5秒

输入格式

  • 第1行:三个空格分隔整数 $R$、$C$、$Q$。
  • 第 $2,\ldots,R+1$ 行:第 $i+1$ 行包含 $C$ 个字符,每个为 '0' 或 '1',表示网格第 $i$ 行。
  • 第 $R+2,\ldots,R+Q+1$ 行:第 $R+i+1$ 行有五个空格分隔整数,代表涂漆操作:$R1_{i}$、$R2_{i}$、$C1_{i}$、$C2_{i}$、$X_{i}$。

输出格式

  • 第 $1,\ldots,Q$ 行:在第 $i+1$ 行输出一个整数,表示第 $i$ 次操作后匹配的单位方格数。

样例

输入格式 1

17 15 10
111111101111111
111111000111111
111110000011111
111100000001111
111000000000111
111100000001111
111000000000111
110000000000011
111000000000111
110000000000011
100000000000001
110000000000011
100000000000001
000000000000000
111111000111111
111111000111111
111111000111111
5 8 2 14 1
8 17 3 7 1
4 5 10 15 0
7 16 12 14 1
2 17 13 14 0
2 6 2 3 1
13 14 4 8 1
3 6 6 7 1
1 16 10 11 0
7 16 10 10 0

输出格式 1

113
94
95
91
87
93
91
87
93
93

说明

奶牛想画一棵节日树。

第一次操作后,网格如下:

000000000000000
000000000000000
000000000000000
000000000000000
011111111111110
011111111111110
011111111111110
011111111111110
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000

有113个单位方格与树图中对应方格匹配,下面用 'x' 表示(其他位显示第一次泼漆后的状态):

0000000x0000000
000000xxx000000
00000xxxxx00000
0000xxxxxxx0000
0xx111111111xx0
0xxx1111111xxx0
0xx111111111xx0
0x11111111111x0
000xxxxxxxxx000
00xxxxxxxxxxx00
0xxxxxxxxxxxxx0
00xxxxxxxxxxx00
0xxxxxxxxxxxxx0
xxxxxxxxxxxxxxx
000000xxx000000
000000xxx000000
000000xxx000000

题目作者:Brian Hamrick 和 Neal Wu, 2008

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.