47 lines
987 B
C++
47 lines
987 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(0);
|
|
cin.tie(0);
|
|
|
|
map<char, vector<pair<int, int>>> nodes;
|
|
string line;
|
|
vector<string> lines;
|
|
while (getline(cin, line) && !line.empty()) {
|
|
lines.push_back(line);
|
|
}
|
|
|
|
int mx = lines.size(), my = lines[0].size();
|
|
|
|
for (int x = 0; x < mx; x++) {
|
|
for (int y = 0; y < my; y++) {
|
|
char c = lines[x][y];
|
|
if (c != '.') {
|
|
nodes[c].push_back({x, y});
|
|
}
|
|
}
|
|
}
|
|
|
|
set<pair<int, int>> total;
|
|
for (auto &[c, poss] : nodes) {
|
|
for (int a = 1; a < poss.size(); a++) {
|
|
for (int b = 0; b < a; b++) {
|
|
vector<pair<int, int>> pos = {
|
|
{poss[b].first * 2 - poss[a].first,
|
|
poss[b].second * 2 - poss[a].second},
|
|
{poss[a].first * 2 - poss[b].first,
|
|
poss[a].second * 2 - poss[b].second}};
|
|
for (auto &x : pos) {
|
|
if (x.first >= 0 && x.first < mx && x.second >= 0 &&
|
|
x.second < my) {
|
|
total.insert(x);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cout << total.size() << '\n';
|
|
}
|