#include <iostream>
using namespace std;
const int MAXN = 3001;
int n, m;
char tablica[MAXN][MAXN];
bool moze_poziomo[MAXN][MAXN];
bool moze_pionowo_w_dol[MAXN][MAXN];
bool uzyte[MAXN][MAXN];
int wynik = 0;
void sprawdz(int y, int x) {
if (((x+2) < m) && tablica[y][x] == 'R' && tablica[y][x + 1] == 'G' && tablica[y][x + 2] == 'W') {
moze_poziomo[y][x] = true;
}
if (((y + 2) < n) && tablica[y][x] == 'R' && tablica[y + 1][x] == 'G' && tablica[y + 2][x] == 'W') {
moze_pionowo_w_dol[y][x] = true;
}
}
void zrob(int y, int x) {
if (moze_poziomo[y][x] && (!uzyte[y][x + 1]) && (!uzyte[y][x + 2])) {
wynik++;
uzyte[y][x] = uzyte[y][x + 2] = uzyte[y][x + 1] = true;
return;
}
if (moze_poziomo[y][x] && (uzyte[y][x + 1]) && (!uzyte[y][x + 2])) {
uzyte[y + 1][x + 1] = false;
uzyte[y][x] = uzyte[y][x + 1] = uzyte[y][x + 2] = true;
return;
}
if (moze_poziomo[y][x] && uzyte[y][x + 1] && uzyte[y][x + 2] && moze_poziomo[y - 1][x + 1]) {
uzyte[y + 1][x + 1] = false;
uzyte[y][x] = uzyte[y][x + 1] = uzyte[y][x + 2] = true;
return;
}
if (moze_pionowo_w_dol[y][x]) {
wynik++;
uzyte[y][x] = uzyte[y + 1][x] = uzyte[y + 2][x] = true;
return;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; n > i; i++) {
for (int j = 0; m > j; j++) {
cin >> tablica[i][j];
}
}
for (int i = 0; n > i; i++) {
for (int j = 0; m > j; j++) {
sprawdz(i, j);
}
}
for (int i = 0; n > i; i++) {
for (int j = 0; m > j; j++) {
zrob(i, j);
}
}
cout << wynik;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
1 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
2 ms |
4432 KB |
Output is correct |
11 |
Correct |
2 ms |
6480 KB |
Output is correct |
12 |
Correct |
2 ms |
6652 KB |
Output is correct |
13 |
Correct |
2 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Correct |
1 ms |
4432 KB |
Output is correct |
16 |
Correct |
2 ms |
4432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
1 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
2 ms |
4432 KB |
Output is correct |
11 |
Correct |
2 ms |
6480 KB |
Output is correct |
12 |
Correct |
2 ms |
6652 KB |
Output is correct |
13 |
Correct |
2 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Correct |
1 ms |
4432 KB |
Output is correct |
16 |
Correct |
2 ms |
4432 KB |
Output is correct |
17 |
Correct |
2 ms |
6480 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
19 |
Correct |
2 ms |
6480 KB |
Output is correct |
20 |
Incorrect |
1 ms |
6480 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
1 ms |
6480 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
2 ms |
4432 KB |
Output is correct |
11 |
Correct |
2 ms |
6480 KB |
Output is correct |
12 |
Correct |
2 ms |
6652 KB |
Output is correct |
13 |
Correct |
2 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
4432 KB |
Output is correct |
15 |
Correct |
1 ms |
4432 KB |
Output is correct |
16 |
Correct |
2 ms |
4432 KB |
Output is correct |
17 |
Correct |
2 ms |
6480 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
19 |
Correct |
2 ms |
6480 KB |
Output is correct |
20 |
Incorrect |
1 ms |
6480 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |