【題目敘述】https://zerojudge.tw/ShowProblem?problemid=b550
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m, ans, g[15][15], t[4][3][3] = {{{1, 1, 1}, {0, 1, 0}, {0, 0, 0}}, {{1, 0, 0}, {1, 1, 0}, {1, 0, 0}},
{{0, 1, 0}, {1, 1, 1}, {0, 0, 0}}, {{0, 1, 0}, {1, 1, 0}, {0, 1, 0}}};
string s;
vector <string> v;
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++){
cin >> s;
for (int j = 0; j < m; j++){
if (s[j] == 'O') g[j][i] = 1;
}
}
swap(n, m);
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
for (int k = 0; k < 4; k++){
bool flag = true;
for (int x = 0; x < 3; x++){
for (int y = 0; y < 3; y++){
if (t[k][x][y] && !g[i+x][j+y]) flag = false;
}
}
if (flag){
ans++;
string str = "";
for (int x = 0; x < 3; x++){
for (int y = 0; y < 3; y++){
if (t[k][x][y]) str += to_string(i+x)+to_string(j+y);
}
}
v.push_back(str);
}
}
}
}
cout << ans << "\n";
sort(v.begin(), v.end());
for (auto i:v){
for (int j = 0; j < 4; j++){
cout << " (" << i[j*2] << "," << i[j*2+1] << ") ";
}
cout << "\n";
}
}