QOJ.ac

QOJ

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

#22367. 節日繪畫

الإحصائيات

為展現節日熱情,乳牛想畫一幅畫!畫是由單位方格組成的 $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.