Mono
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 [] 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.
[c]3 3
aaa
aaa
aaa
4
2 0
2 2
0 2
0 0
Output
43 3
aaa
aba
aaa
4
2 0
2 2
0 2
0 0 Output
0Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.