#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define yes "YES"
#define no "NO"
#define bigg INT_MAX
#define debug(x) cout<<(#x)<<" = " <<x<<endl;
#define all(x) x.begin(),x.end()
#define sz size()
#define nn '\n'
#define mms(x,y) memset(x,y,sizeof(x))
#define forr(i,j,n) for (int i=j; i<n; i++)
#define forn(i,j,n) for (int i=j; i>n; i--)
#define fi first
#define se second
#define la "LA"
#define cinn(x,y) for(int i=0; i<y; i++) cin>>x[i];
#define pii pair<int,int>
signed main()
{
// #ifndef LOCAL
// freopen("helpcross.in","r",stdin);
// freopen("helpcross.out","w", stdout);
// #endif
fast
int n,m;
cin>>n >>m;
int d[6]={ };
string a[n];
forr(i,0,n) cin>>a[i];
forr(i,0,n-1)
{
forr(j,0,m-1)
{
if (a[i][j]!='.' && a[i][j]==a[i+1][j] && a[i][j]==a[i][j+1] && a[i][j]==a[i+1][j+1]) d[1]++;
}
}
forr(i,0,n)
{
forr(j,0,m-3)
{
if (a[i][j]!='.' && a[i][j]==a[i][j+1] && a[i][j]==a[i][j+2] && a[i][j]==a[i][j+3]) d[2]++;
}
}
forr(i,0,n-3)
{
forr(j,0,m)
{
if (a[i][j]!='.' && a[i][j]==a[i+1][j] && a[i][j]==a[i+2][j] && a[i][j]==a[i+3][j]) d[2]++;
}
}
forr(i,1,n)
{
forr(j,0,m-2)
{
if (a[i][j]!='.' && a[i][j]==a[i][j+1] && a[i][j]==a[i][j+2] && a[i][j]==a[i-1][j+1]) d[5]++;
}
}
forr(i,0,n-1)
{
forr(j,0,m-2)
{ if (a[i][j]!='.' && a[i][j]==a[i][j+1] && a[i][j]==a[i][j+2] && a[i][j]==a[i+1][j+1]) d[5]++;
}
}
forr(i,0,n-2)
{
forr(j,1,m)
{
if (a[i][j]!='.' && a[i][j]==a[i+1][j] && a[i][j]==a[i+2][j] && a[i+1][j-1]==a[i][j]) d[5]++;
}
}
forr(i,0,n-2)
{
forr(j,0,m-1)
{
if (a[i][j]!='.' && a[i][j]==a[i+1][j] && a[i][j]==a[i+2][j] && a[i+1][j+1]==a[i][j]) d[5]++;
}
}
forr(i,1,n)
{
forr(j,0,m-2)
{
if (a[i][j]!='.' && a[i][j]==a[i][j+1] && a[i][j]==a[i-1][j+2] && a[i][j]==a[i-1][j+1]) d[3]++;
}
}
forr(i,0,n-2)
{
forr(j,0,m-1)
{
if (a[i][j]!='.' && a[i][j]==a[i+1][j] && a[i][j]==a[i+1][j+1] && a[i][j]==a[i+2][j+1]) d[3]++;
}
}
forr(i,0,n-1)
{
forr(j,0,m-2)
{
if (a[i][j]!='.' && a[i][j]==a[i][j+1] && a[i][j]==a[i+1][j+2] && a[i][j]==a[i+1][j+1]) d[4]++;
}
}
forr(i,0,n-2)
{
forr(j,1,m)
{
if (a[i][j]!='.' && a[i][j]==a[i+1][j] && a[i][j]==a[i+1][j-1] && a[i][j]==a[i+2][j-1]) d[4]++;
}
}
cout<<d[1]<<nn<<d[2]<<nn<<d[3]<<nn<<d[4]<<nn<<d[5]<<nn;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
456 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
376 KB |
Output is correct |