영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
You are given an n × n grid representing the map of a forest. Each square is either empty or has a tree. Your task is to process q queries of the following types:
- Change the state (empty/tree) of a square.
- How many trees are inside a rectangle in the forest?
Input
The first input line has two integers n and q: the size of the forest and the number of queries.
Then, there are n lines describing the forest. Each line has n characters: . is an empty square and * is a tree.
Finally, there are q lines describing the queries. The format of each line is either "1 y x" or "2 y_1 x_1 y_2 x_2".
Output
Print the answer to each query of the second type.
Constraints
- 1 ≤ n ≤ 1000
- 1 ≤ q ≤ 2 · 10^5
- 1 ≤ y,x ≤ n
- 1 ≤ y_1 ≤ y_2 ≤ n
- 1 ≤ x_1 ≤ x_2 ≤ n
예제
예제 1
4 3 .*.. *.** **.. **** 2 2 2 3 4 1 3 3 2 2 2 3 4
3 4