atcoder#ABC260G. [ABC260G] Scalene Triangle Area
[ABC260G] Scalene Triangle Area
Score : points
Problem Statement
We have an grid. The square at the -th row from the top and -th column from the left in this grid is called . Each square of the grid has at most one piece. The state of the grid is given by strings :
- if the -th character of is
O
, then has a piece on it; - if the -th character of is
X
, then has no piece on it.
You are given an integer . Using this , we define that a piece placed at covers a square if all of the following conditions are satisfied:
For each of squares , find how many pieces cover the square.
Constraints
- , , , , and are integers.
- consists of
O
andX
.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line ( ) should contain the number of pieces that covers as an integer.
4 2
OXXX
XXXX
XXXX
XXXX
6
1 1
1 4
2 2
2 3
3 1
4 4
1
1
1
0
0
0
Only Square contains a piece, which covers the following #
squares:
####
##..
....
....
5 10
OOOOO
OOOOO
OOOOO
OOOOO
OOOOO
5
1 1
2 3
3 4
4 2
5 5
1
6
12
8
25
8 5
OXXOXXOX
XOXXOXOX
XOOXOOXO
OXOOXOXO
OXXOXXOX
XOXXOXOX
XOOXOOXO
OXOOXOXO
6
7 2
8 1
4 5
8 8
3 4
1 7
5
3
9
14
5
3