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 "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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |