atcoder#TENKA12018E. Equilateral
Equilateral
Score : points
Problem Statement
There are some coins in the -plane.
The positions of the coins are represented by a grid of characters with rows and columns.
If the character at the -th row and -th column, , is #
, there is one coin at point ; if that character is .
, there is no coin at point . There are no other coins in the -plane.
There is no coin at point where does not hold. There is also no coin at point where or (or both) is not an integer. Additionally, two or more coins never exist at the same point.
Find the number of triples of different coins that satisfy the following condition:
- Choosing any two of the three coins would result in the same Manhattan distance between the points where they exist.
Here, the Manhattan distance between points and is . Two triples are considered the same if the only difference between them is the order of the coins.
Constraints
- is
#
or.
.
Input
Input is given from Standard Input in the following format:
Output
Print the number of triples that satisfy the condition.
5 4
#.##
.##.
#...
..##
...#
3
and satisfy the condition.
13 27
......#.........#.......#..
#############...#.....###..
..............#####...##...
...#######......#...#######
...#.....#.....###...#...#.
...#######....#.#.#.#.###.#
..............#.#.#...#.#..
#############.#.#.#...###..
#...........#...#...#######
#..#######..#...#...#.....#
#..#.....#..#...#...#.###.#
#..#######..#...#...#.#.#.#
#..........##...#...#.#####
870