#include<iostream>
using namespace std;
int f0,f1,f2,f3,f4,n,m;
char mat[12][12];
int main() {
cin.sync_with_stdio(0); cin.tie(0);
cin.exceptions(cin.failbit);
cin >> n >> m;
for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> mat[i][j];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) {
if(mat[i][j]=='.') continue;
if(i+1<n && j+1<m && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i][j+1] && mat[i][j]==mat[i+1][j+1]) f0++;
if(j+3<m && mat[i][j]==mat[i][j+1] && mat[i][j]==mat[i][j+2] && mat[i][j]==mat[i][j+3]) f1++;
if(i+3<n && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i+2][j] && mat[i][j]==mat[i+3][j]) f1++;
if(i+1<n && j+1<m && j-1>=0 && mat[i][j]==mat[i][j+1] && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i+1][j-1]) f2++;
if(i+2<n && j+1<m && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i+1][j+1] && mat[i][j]==mat[i+2][j+1]) f2++;
if(i+1<n && j+2<m && mat[i][j]==mat[i][j+1] && mat[i][j]==mat[i+1][j+1] && mat[i][j]==mat[i+1][j+2]) f3++;
if(i+2<n && j-1>=0 && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i+1][j-1] && mat[i][j]==mat[i+2][j-1]) f3++;
if(i+1<n && j+1<m && j-1>=0 && mat[i][j]==mat[i+1][j-1] && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i+1][j+1]) f4++;
if(i+1<n && j+2<m && mat[i][j]==mat[i][j+1] && mat[i][j]==mat[i][j+2] && mat[i][j]==mat[i+1][j+1]) f4++;
if(i+2<n && j-1>=0 && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i+2][j] && mat[i][j]==mat[i+1][j-1]) f4++;
if(i+2<n && j+1<m && mat[i][j]==mat[i+1][j] && mat[i][j]==mat[i+2][j] && mat[i][j]==mat[i+1][j+1]) f4++;
}
cout << f0 << "\n" << f1 << "\n" << f2 << "\n" << f3 << "\n" << f4;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |