#P8325. [COCI 2021/2022 #5] Dijamant
[COCI 2021/2022 #5] Dijamant
Problem Description
Several “diamonds” are placed on the table.
When a square is rotated by , it forms a “rhombus” shape. A shape whose outline looks like a “rhombus”, with the entire outer border made of and the entire interior made of is defined as one “diamond”.
Given a table of size , count how many “diamonds” are placed on the table.
Input Format
The first line contains two positive integers , representing the size of the table.
The next lines each contain characters or , representing the table.
Output Format
The number of “diamonds”.
7 25
.#...#....#....#.....#...
#.#..#...#.#...#....#.#..
.#...#..#...#..#...#...#.
.....#...#.#...#..#.....#
.....#....#....#...#...#.
.....#.........#....#.#..
.....#.........#.....#...
3
11 17
.....#........#..
....#.#........#.
...#...#....#...#
..#.....#....#.#.
.#....#..#....#..
#....#.#..#......
.#....#..#.......
..#.....#........
...#...#.........
....#.#..........
.....#...........
1
5 11
##.#.#.#.##
#.#.#.#.#.#
.#.#.#.#.#.
#.#.#.#.#.#
##.#.#.#.##
14
Hint
[Sample 2 Explanation]
It looks like there are diamonds, but in fact two “rhombuses” contain each other, so they do not meet the definition “outer border is all but the interior is all ”. Therefore, there is only diamond.
[Constraints and Notes]
This problem uses bundled tests.
- Subtask 1 (20 pts): .
- Subtask 2 (50 pts): no special restrictions.
For of the testdata, .
[Source] COCI 2021-2022#5 Task 2 Dijamant.
Translated by ChatGPT 5