#abc260g. G - Scalene Triangle Area
G - Scalene Triangle Area
Score : points
问题描述
我们有一个 的网格。在这个网格中,从上到下第 行、从左到右第 列的方格被称为 。
每个网格方格最多有一个棋子。
网格的状态由 个字符串 给出:
- 如果 的第 个字符是
O
,表示 上有一个棋子; - 如果 的第 个字符是
X
,表示 上没有棋子。
给定一个整数 ,我们定义放置在 的棋子 覆盖了方格 ,当且仅当以下所有条件都满足:
对于 个不同的方格 ,找出覆盖这些方格的棋子数量。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
4 2
OXXX
XXXX
XXXX
XXXX
6
1 1
1 4
2 2
2 3
3 1
4 4
Sample Output 1
1
1
1
0
0
0
Only Square contains a piece, which covers the following #
squares:
####
##..
....
....
Sample Input 2
5 10
OOOOO
OOOOO
OOOOO
OOOOO
OOOOO
5
1 1
2 3
3 4
4 2
5 5
Sample Output 2
1
6
12
8
25
Sample Input 3
8 5
OXXOXXOX
XOXXOXOX
XOOXOOXO
OXOOXOXO
OXXOXXOX
XOXXOXOX
XOOXOOXO
OXOOXOXO
6
7 2
8 1
4 5
8 8
3 4
1 7
Sample Output 3
5
3
9
14
5
3
update @ 2024/3/10 11:02:33