RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00168

Mono

Platinum III 플래티넘 III
난이도
5s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Mirko soon realised that number sequences are not the best career choice, and went right back to the letter-table business.

Mirko's table has \(R\) rows and \(C\) columns and consists of lowercase letters. Each cell of the table is a square of equal size. We assign coordinates to the vertices of those squares, so that the upper-left corner of the table has coordinates \((0, 0)\), the upper-right \((C, 0)\), the lower-left \((0, R)\), and the lower-right \((C, R)\).

We say that a polygon within the table is monoliteral if the following holds:

  1. its vertices are from the described set of cell-square vertices,
  2. its edges are parallel to the coordinate axes,
  3. all letters inside the polygon are equal.

A simple polygon for which the first two conditions are true (the third one may or may not be true) is given. Mirko would like to know the number of monoliteral polygons that can be obtained by moving the given one up, down, left, or right (or any combination thereof), but not rotating.

제약

In test cases worth 40% of total points, R, C and V will not exceed 20.
In test cases worth 70% of total points, V will not exceed 20.

\(3^{rd}\) round, December \(11^{th}\) 2010

EXAMPLE TEST DATA
input

3 3
aaa
aaa
aaa
4
2 0
2 2
0 2
0 0

input

3 3
aaa
aba
aaa
4
2 0
2 2
0 2
0 0

input

5 4
xyyx
xyyy
xxyy
xxxx
xxxx
8
1 3
1 2
0 2
0 0
2 0
2 1
3 1
3 3
output

4
output

0
output

2

입력 형식

The first line of input contains two space separated integers \(R\) and \(C\) (\(1 \le R, C \le 500\)).

Each of the next \(R\) lines contains exactly \(C\) lowercase letters, this is Mirko's table.

The following line contains an integer \(V\) (\(4 \le V \le 500\)), the number of vertices of the given polygon.

Each of the next \(V\) lines contains two integers \(X\), \(Y\) (\(0 \le X \le C\), \(0 \le Y \le R\)), the coordinates of the vertices of the given polygon. Vertices are given in clockwise order. The given polygon will satisfy conditions \(1\) and \(2\) from above.

출력 형식

In the first and only line of output, print the expected number of polygons.

Scoring: Test cases worth \(40\%\) of total points have \(R\), \(C\) and \(V\) not exceeding \(20\). Test cases worth \(70\%\) of total points have \(V\) not exceeding \(20\).

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
3 3
aaa
aaa
aaa
4
2 0
2 2
0 2
0 0
출력
4
예제 2
입력
3 3
aaa
aba
aaa
4
2 0
2 2
0 2
0 0
출력
0
예제 3
입력
5 4
xyyx
xyyy
xxyy
xxxx
xxxx
8
1 3
1 2
0 2
0 0
2 0
2 1
3 1
3 3
출력
2
문제 정보

riseoj 작성

출처 COCI 2010/2011 Contest 3

평가 및 의견

Mono

개요
출제자 난이도 Platinum III 플래티넘 III 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Mono

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