Submission #1072658

# Submission time Handle Problem Language Result Execution time Memory
1072658 2024-08-24T02:10:48 Z pavement Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
2 ms 348 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;

using ii = pair<int, int>;

#define eb emplace_back

vector<ii> cells, nodes, horiz, vert;

void init(int R, int C, int sr, int sc, int M, char *S) {
	for (int i = 0; i < M; i++) {
		if (S[i] == 'N') {
			sr--;
		} else if (S[i] == 'S') {
			sr++;
		} else if (S[i] == 'E') {
			sc++;
		} else {
			sc--;
		}
		cells.eb(sr, sc);
	}
	sort(cells.begin(), cells.end());
	cells.erase(unique(cells.begin(), cells.end()), cells.end());
	for (auto [r, c] : cells) {
		nodes.eb(r, c);
		nodes.eb(r + 1, c);
		nodes.eb(r, c + 1);
		nodes.eb(r + 1, c + 1);
		horiz.eb(r, c);
		horiz.eb(r + 1, c);
		vert.eb(r, c);
		vert.eb(r, c + 1);
	}
	for (auto *vec : {&nodes, &horiz, &vert}) {
		sort(vec->begin(), vec->end());
		vec->erase(unique(vec->begin(), vec->end()), vec->end());
	}
}

int colour(int ar, int ac, int br, int bc) {
	int V = (br - ar + 1) * 2 + (bc - ac + 1) * 2 - 4, E = V;
	for (auto [r, c] : nodes) {
		if (ar + 1 <= r && r <= br && ac + 1 <= c && c <= bc) {
			V++;
		}
	}
	for (auto [r, c] : horiz) {
		if (ar + 1 <= r && r <= br && ac <= c && c <= bc) {
			E++;
		}
	}
	for (auto [r, c] : vert) {
		if (ar <= r && r <= br && ac + 1 <= c && c <= bc) {
			E++;
		}
	}
	int F = 2 - (V - E), water_F = 0;
	for (auto [r, c] : cells) {
		if (ar <= r && r <= br && ac <= c && c <= bc) {
			water_F++;
		}
	}
	return F - water_F - 1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -