#SRD0000009. Đếm cây trong hình chữ nhật có cập nhật (Forest Queries II)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm cây trong hình chữ nhật có cập nhật (Forest Queries II)
Forest Queries II
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
A forest is an grid where * denotes a tree and . an empty cell. Process operations in order: type 1 y x toggles the state of exactly one cell, and type 2 y1 x1 y2 x2 counts the trees within the inclusive rectangle with the specified opposite corners. All earlier toggles affect the current query.
Input
The first line contains , followed by grid rows of exactly characters each (. or *). Each of the next lines is 1 y x (toggle cell) or 2 y1 x1 y2 x2 (count trees).
Output
For each query requesting a result, output one integer on its own line in input order. Update operations produce no output.
Subtasks
- Subtask 1 (10 points): ; ; Every row has exactly characters from
{., *}; , , . - Subtask 2 (20 points): ; ; Every row has exactly characters from
{., *}; , , . - Subtask 3 (30 points): ; ; Every row has exactly characters from
{., *}; , , . - Subtask 4 (40 points): ; ; Every row has exactly characters from
{., *}; , , .
Examples
Input
4 3
.*..
*.**
**..
****
2 2 2 3 4
1 3 3
2 2 2 3 4
Output
3
4
Explanation
Initially the rectangle from to contains trees. Cell was empty and the update toggles it to a tree. The subsequent query returns .