#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 10;
int m, n, answer[5];
char a[N][N];
void ReadInput(){
cin >> m >> n;
for(int i = 0; i < m; i++)
cin >> a[i];
}
void Count(vector<vector<int>> p, int &cnt){
int r = p.size();
int c = p[0].size();
for(int i = 0; i < m - r + 1; i++)
for(int j = 0; j < n - c + 1; j++){
int mi = 1000, ma = 0;
for(int k = 0; k < r; k++)
for(int l = 0; l < c; l++)
if (p[k][l]){
mi = min(mi, (int) a[i + k][j + l]);
ma = max(ma, (int) a[i + k][j + l]);
}
if (mi == ma && mi != '.')
cnt++;
}
}
void Solve(){
Count({{1, 1}, {1, 1}}, answer[0]);
Count({{1, 1, 1, 1}}, answer[1]);
Count({{1}, {1}, {1}, {1}}, answer[1]);
Count({{0, 1, 1}, {1, 1, 0}}, answer[2]);
Count({{1, 0}, {1, 1}, {0, 1}}, answer[2]);
Count({{1, 1, 0}, {0, 1, 1}}, answer[3]);
Count({{0, 1}, {1, 1}, {1, 0}}, answer[3]);
Count({{0, 1, 0}, {1, 1, 1}}, answer[4]);
Count({{1, 1, 1}, {0, 1, 0}}, answer[4]);
Count({{1, 0}, {1, 1}, {1, 0}}, answer[4]);
Count({{0, 1}, {1, 1}, {0, 1}}, answer[4]);
for(int i = 0; i < 5; i++)
cout << answer[i] << '\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ReadInput();
Solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
380 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |