#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'
int main() {
#ifndef ONLINE_JUDGE
//freopen("test.in", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m; cin >> n >> m;
vector<vi> mat(n, vi(m)), ct(n, vi(m));
for_(i, 0, n) for_(j, 0, m) {
char c; cin >> c;
int v = 0;
if (c == 'G') v = 1;
else if (c == 'W') v = 2;
mat[i][j] = v;
}
int ans = 0;
for_(i, 0, n) for_(j, 0, m-2) {
if (mat[i][j] == 0 and mat[i][j+1] == 1 and mat[i][j+2] == 2) {
ct[i][j] += 1; ct[i][j+1] += 1; ct[i][j+2] += 1;
ans += 1;
j += 2;
}
}
for_(j, 0, m) for_(i, 0, n-2) {
if (mat[i][j] == 0 and mat[i+1][j] == 1 and mat[i+2][j] == 2) {
ct[i][j] += 1; ct[i+1][j] += 1; ct[i+2][j] += 1;
ans += 1;
i += 2;
}
}
for_(i, 0, n) for_(j, 0, m) if (ct[i][j] > 1) ans -= 1;
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |