#include<bits/stdc++.h>
using namespace std;
long long n, m, cnt = 0, temp;
bool grid[2001][2001];
string s;
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; ++i)
{
cin >> s;
for(int j = 0; j < m; ++j) if(s[j] == '#') grid[i][j + 1] = true;
}
for(int i = 1; i < n; ++i)
{
for(int j = 2; j < m; ++j)
{
if(grid[i][j])
{
temp = -1;
bool check = 0, done = 0;
for(int k = 1; k <= n; ++k)
{
if(grid[i + k][j - k] == grid[i + k][j + k] && grid[i + k][j - k])
{
for(int l = j - k + 1; l < j + k; ++l)
{
if(grid[i + k][l])
{
check = 1;
break;
}
}
if(check)
{
if(grid[i + k][j - k + 2] == grid[i + k][j + k - 2] && grid[i + k][j - k + 2])
{
done = 1;
temp = k - 1;
check = 0;
if(temp < 1) check = 1;
}
}
}
else if(grid[i + k][j - k + 2] == grid[i + k][j + k - 2] && grid[i + k][j - k + 2])
{
done = 1;
temp = k - 1;
if(temp < 1) check = 1;
}
else check = 1;
if(check || done) break;
}
if(done)
{
if(temp + i > n)
{
check = 1;
continue;
}
int temp2 = temp - 1;
while(temp2 >= 0)
{
if(grid[i + temp * 2 - temp2][j - temp2] == grid[i + temp * 2 - temp2][j + temp2] && grid[i + temp * 2 - temp2][j - temp2])
{
for(int l = j - temp2 + 1; l < j - temp2; ++l)
{
if(grid[i + temp * 2 - temp2][l])
{
check = 1;
break;
}
}
}
else check = 1;
if(check) break;
--temp2;
}
}
if(!check && done)
{
++cnt;
}
}
}
}
cout << cnt << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |