#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_pionowo_w_dol[y][x]) {
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]) && y < (n - 1) && uzyte[y + 1][x]) {
uzyte[y + 1][x] = 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] = false;
uzyte[y][x] = uzyte[y][x + 1] = uzyte[y][x + 2] = 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 |
1 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 |
Incorrect |
1 ms |
6616 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 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 |
Incorrect |
1 ms |
6616 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 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 |
Incorrect |
1 ms |
6616 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |