This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |