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$ は5整数 $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行目:空白区切りの3整数 $R$、$C$、$Q$。
  • $2,\ldots,R+1$ 行目:$i+1$ 行目は各々 '0' か '1' の $C$ 文字で、格子の $i$ 行目を表します。
  • $R+2,\ldots,R+Q+1$ 行目:$R+i+1$ 行目は塗る操作を表す空白区切りの5整数 $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.