포럼
문제 ICPC00361

H. Horse Habitat

설명

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
출력
3
예제 2
입력
3 3 6
..#
#..
...
1 1
1 2
2 1
3 1
2 2
3 3
출력
7
4
3
1
1
0
예제 3
입력
2 3 6
...
...
1 1
1 2
2 1
2 2
1 3
2 3
출력
6
4
3
2
2
1
예제 4
입력
3 5 5
.....
..#..
.....
2 2
1 1
1 5
3 1
1 3
출력
4
14
2
4
6
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC BAPC 2024

평가 및 의견

H. Horse Habitat

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

H. Horse Habitat

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8