A1199 | [COCI-2010_2011-contest3]#3 MONO
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mirko soon realised that number sequences are not the best career choice, and went right back to 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 vertices of those squares, so that upper-left corner of the table has coordinates (0, 0), upper-right (C,0), lower-left (0, R), and lower-right (C, R).
We say that 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 coordinate axes,
3. all letters inside the polygon are equal.
A simple polygon for which first two conditions are true (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.
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 vertices of those squares, so that upper-left corner of the table has coordinates (0, 0), upper-right (C,0), lower-left (0, R), and lower-right (C, R).
We say that 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 coordinate axes,
3. all letters inside the polygon are equal.
A simple polygon for which first two conditions are true (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.
输入格式
The first line of input contains two space seperated integers R and C (1 ≤ R, C ≤ 500).
Each of the next R lines contains exactly C lowercase letters, this is Mirko’s table.
The following line contains integer V (4 ≤ V ≤ 500), number of vertices of given polygon.
Each of the next V lines contains two integers X, Y (0 ≤ X ≤ C, 0 ≤ Y ≤ R). These are 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.
Each of the next R lines contains exactly C lowercase letters, this is Mirko’s table.
The following line contains integer V (4 ≤ V ≤ 500), number of vertices of given polygon.
Each of the next V lines contains two integers X, Y (0 ≤ X ≤ C, 0 ≤ Y ≤ R). These are 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 expected number of polygons.
输入输出样例
输入 #1
3 3 aaa aaa aaa 4 2 0 2 2 0 2 0 0
输出 #1
4
输入 #2
3 3 aaa aba aaa 4 2 0 2 2 0 2 0 0
输出 #2
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
输出 #3
2
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.
In test cases worth 70% of total points, V will not exceed 20.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted