#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
vector<pi> pnt, vtx, edx, edy;
int minx = 1e9, miny = 1e9, maxx = -1e9, maxy = -1e9;
void init(int R, int C, int sr, int sc, int M, char *S) {
auto upload = [&](int x, int y){
pnt.emplace_back(x, y);
vtx.emplace_back(x, y);
vtx.emplace_back(x+1, y);
vtx.emplace_back(x, y+1);
vtx.emplace_back(x+1, y+1);
edx.emplace_back(x, y);
edx.emplace_back(x, y+1);
edy.emplace_back(x, y);
edy.emplace_back(x+1, y);
minx = min(minx, x); maxx = max(maxx, x + 1);
miny = min(miny, y); maxy = max(maxy, y + 1);
};
upload(sr, sc);
for(int i=0; i<M; i++){
if(S[i] == 'N') sr--;
if(S[i] == 'S') sr++;
if(S[i] == 'E') sc++;
if(S[i] == 'W') sc--;
upload(sr, sc);
}
auto normalize = [&](vector<pi> &v){
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end()) - v.begin());
};
normalize(pnt);
normalize(vtx);
normalize(edx);
normalize(edy);
}
bool in(int sx, int ex, int sy, int ey, pi x){
return sx <= x.first && x.first <= ex && sy <= x.second && x.second <= ey;
}
int colour(int ar, int ac, int br, int bc) {
if(ar < minx && maxx < br + 1 && ac < miny && maxy < bc + 1){
return 1;
}
int V = 0;
int E = 0;
int F = 0;
for(auto &i : vtx){
if(in(ar + 1, br, ac + 1, bc, i)) V++;
}
for(auto &i : edx){
if(in(ar, br, ac + 1, bc, i)) E++;
}
for(auto &i : edy){
if(in(ar + 1, br, ac, bc, i)) E++;
}
for(auto &i : pnt){
if(in(ar, br, ac, bc, i)) F++;
}
// printf("%d %d %d\n", V, E, F);
if(F == 0) return 1;
return 1 + E - V - F;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
12 ms |
512 KB |
Output is correct |
3 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Execution timed out |
3021 ms |
6784 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
62 ms |
9324 KB |
Output is correct |
3 |
Correct |
35 ms |
9324 KB |
Output is correct |
4 |
Correct |
34 ms |
9324 KB |
Output is correct |
5 |
Correct |
39 ms |
8688 KB |
Output is correct |
6 |
Correct |
71 ms |
9324 KB |
Output is correct |
7 |
Incorrect |
80 ms |
9324 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
12 ms |
512 KB |
Output is correct |
3 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
12 ms |
512 KB |
Output is correct |
3 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |