8a9b42d18b
This is just the Haskell solution but better because that was so imperative anyways
30 lines
600 B
C++
30 lines
600 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
inline bool isMas(char a, char b) {
|
|
return (a == 'M' && b == 'S') || (a == 'S' && b == 'M');
|
|
}
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(0);
|
|
cin.tie(0);
|
|
|
|
vector<string> lines;
|
|
string line;
|
|
while (getline(cin, line) && !line.empty()) {
|
|
lines.push_back(line);
|
|
}
|
|
|
|
int n = 0;
|
|
for (int x = 1; x < lines.size() - 1; x++) {
|
|
for (int y = 1; y < lines[x].size() - 1; y++) {
|
|
if (lines[x][y] == 'A' &&
|
|
isMas(lines[x - 1][y - 1], lines[x + 1][y + 1]) &&
|
|
isMas(lines[x - 1][y + 1], lines[x + 1][y - 1])) {
|
|
n++;
|
|
}
|
|
}
|
|
}
|
|
cout << n << '\n';
|
|
}
|