Logo
(追記) (追記ここまで)

32602번 - Horse Habitat 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
25 초 2048 MB65271848.649%

문제

Harold has inherited a huge habitat with hundreds of horses! He wants to train a handful of horses for the Bareback Arizona Phoenix Cowboys, which is a half-yearly happening honouring Arizonan horse riding history. Hence, Harold signed his horses up for the Hurdle Hopping event and he has requested your help handling the training program.

Hurdle Hopping courses have many possible layouts, each requiring a different rectangular area. However, not all of the land in the habitat is suitable for courses. Horses, moreover, need to train courses on multiple different grounds in order to learn to adapt to possible circumstances. Handling the training program, it is thus relevant that courses can be rebuilt in many different locations.

Handed to you is a map showing the habitat as a grid of unit squares with each square indicating whether the land is suitable for courses or not. Help Harold by answering a list of questions, each question asking the total number of possible locations in the habitat for a Hurdle Hopping course with a particular size.

입력

The input consists of:

  • One line with three integers $r,ドル $c,ドル and $q$ (1ドル \leq r,c \leq 9 \cdot 10^6,ドル $r \cdot c \leq 9 \cdot 10^6,ドル 1ドル \leq q \leq 10^5$), the number of rows and columns of the grid, and the number of questions.
  • $r$ lines with $c$ characters, each character being either '.' if the corresponding square indicates land suitable for courses or '#' otherwise.
  • $q$ lines, each with two integers $h$ and $w$ (1ドル \leq h \leq r,ドル 1ドル \leq w \leq c$), indicating a question from Harold about the number of Hurdle Hopping courses with height $h$ (number of rows in the grid) and width $w$ (number of columns in the grid).

출력

For each of the $q$ questions, output the number of possible locations for a grid-aligned Hurdle Hopping course of the requested height $h$ (number of rows in the grid) and width $w$ (number of columns in the grid).

제한

예제 입력 1

1 7 1
#....#.
1 2

예제 출력 1

3

예제 입력 2

3 3 6
..#
#..
...
1 1
1 2
2 1
3 1
2 2
3 3

예제 출력 2

7
4
3
1
1
0

예제 입력 3

2 3 6
...
...
1 1
1 2
2 1
2 2
1 3
2 3

예제 출력 3

6
4
3
2
2
1

예제 입력 4

3 5 5
.....
..#..
.....
2 2
1 1
1 5
3 1
1 3

예제 출력 4

4
14
2
4
6

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2024 H번

  • 문제를 만든 사람: Mike de Vries

채점 및 기타 정보

  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /