제출 #1115348

#제출 시각아이디문제언어결과실행 시간메모리
1115348staszic_ojuzDango Maker (JOI18_dango_maker)C++17
13 / 100
2 ms6648 KiB
#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 + 1][x] = uzyte[y + 2][x] = 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;
	}
}

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...