#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
typedef long long llong;
const int MAXN = 3000 + 10;
const int INF = 1e9;
int n, m;
char s[MAXN][MAXN];
bool used[MAXN][MAXN];
inline bool tryHorizontal(int stX, int stY)
{
if (stY + 2 >= m+1) return false;
return !used[stX][stY] && !used[stX][stY + 1] && !used[stX][stY + 2] && s[stX][stY] == 'R' && s[stX][stY + 1] == 'G' && s[stX][stY + 2] == 'W';
}
inline bool tryVertical(int stX, int stY)
{
if (stX + 2 >= n+1) return false;
return !used[stX][stY] && !used[stX + 1][stY] && !used[stX + 2][stY] && s[stX][stY] == 'R' && s[stX + 1][stY] == 'G' && s[stX + 2][stY] == 'W';
}
void solve()
{
int ans = 0;
for (int row = 1 ; row <= n ; ++row)
{
for (int col = 1 ; col <= m ; ++col)
{
if (tryHorizontal(row, col))
{
used[row][col] = true;
used[row][col + 1] = true;
used[row][col + 2] = true;
ans++;
}
}
for (int col = 1 ; col <= m ; ++col)
{
if (tryVertical(row, col))
{
used[row][col] = true;
used[row + 1][col] = true;
used[row + 2][col] = true;
ans++;
}
}
}
std::cout << ans << '\n';
}
void read()
{
std::cin >> n >> m;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> s[i]+1;
}
}
void fastIO()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIO();
read();
solve();
return 0;
}
Compilation message
dango_maker.cpp: In function 'void read()':
dango_maker.cpp:64:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
64 | std::cin >> s[i]+1;
| ~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
324 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
324 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
324 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
324 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
324 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
324 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
328 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
324 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
324 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
324 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
328 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |