Submission #1072666

# Submission time Handle Problem Language Result Execution time Memory
1072666 2024-08-24T02:17:15 Z pavement Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
3000 ms 10948 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) {
	cells.eb(sr, sc);
	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 (const 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;
	bool border = 0;
	for (const auto &[r, c] : nodes) {
		if (ar + 1 <= r && r <= br && ac + 1 <= c && c <= bc) {
			V++;
		} else if (((ar == r || br + 1 == r) && (ac <= c && c <= bc + 1)) || ((ac == c || bc + 1 == c) && (ar <= r && r <= br + 1))) {
			border = 1;
		}
	}
	if (!border) {
		return 1;
	}
	for (const auto &[r, c] : horiz) {
		if (ar + 1 <= r && r <= br && ac <= c && c <= bc) {
			E++;
		}
	}
	for (const auto &[r, c] : vert) {
		if (ar <= r && r <= br && ac + 1 <= c && c <= bc) {
			E++;
		}
	}
	int F = 2 - (V - E), water_F = 0;
	for (const 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 Correct 2 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Execution timed out 3093 ms 6888 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 39 ms 10744 KB Output is correct
3 Correct 20 ms 10948 KB Output is correct
4 Correct 20 ms 10676 KB Output is correct
5 Correct 21 ms 10396 KB Output is correct
6 Correct 14 ms 3900 KB Output is correct
7 Incorrect 22 ms 5580 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -