#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
int xmin, xmax, ymin, ymax;
set<pair<int, int>> vertex, edge_v, edge_h, face;
void init(int R, int C, int sr, int sc, int M, char *S){
sr--;
sc--;
vector<int> x(M + 1), y(M + 1);
x[0] = sr;
y[0] = sc;
for (int i = 0; i < M; i++){
x[i + 1] = x[i];
y[i + 1] = y[i];
if (S[i] == 'N'){
x[i + 1]--;
}
if (S[i] == 'S'){
x[i + 1]++;
}
if (S[i] == 'E'){
y[i + 1]++;
}
if (S[i] == 'W'){
y[i + 1]--;
}
}
xmin = sr;
xmax = sr;
ymin = sc;
ymax = sc;
for (int i = 1; i <= M; i++){
xmin = min(xmin, x[i]);
xmax = max(xmax, x[i]);
ymin = min(ymin, y[i]);
ymax = max(ymax, y[i]);
}
for (int i = 0; i <= M; i++){
vertex.insert(make_pair(x[i], y[i]));
edge_v.insert(make_pair(x[i], y[i]));
edge_v.insert(make_pair(x[i] - 1, y[i]));
edge_h.insert(make_pair(x[i], y[i]));
edge_h.insert(make_pair(x[i], y[i] - 1));
face.insert(make_pair(x[i], y[i]));
face.insert(make_pair(x[i] - 1, y[i]));
face.insert(make_pair(x[i], y[i] - 1));
face.insert(make_pair(x[i] - 1, y[i] - 1));
}
}
int colour(int ar, int ac, int br, int bc){
ar--;
ac--;
int ans = 1;
for (auto P : vertex){
if (ar <= P.first && P.first < br && ac <= P.second && P.second < bc){
ans--;
}
}
for (auto P : edge_v){
if (ar <= P.first && P.first < br - 1 && ac <= P.second && P.second < bc){
ans++;
}
}
for (auto P : edge_h){
if (ar <= P.first && P.first < br && ac <= P.second && P.second < bc - 1){
ans++;
}
}
for (auto P : face){
if (ar <= P.first && P.first < br - 1 && ac <= P.second && P.second < bc - 1){
ans--;
}
}
if (ar < xmin && xmax < br - 1 && ac < ymin && ymax < bc - 1){
ans++;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
340 KB |
Output is correct |
2 |
Correct |
43 ms |
564 KB |
Output is correct |
3 |
Correct |
9 ms |
392 KB |
Output is correct |
4 |
Correct |
12 ms |
340 KB |
Output is correct |
5 |
Correct |
52 ms |
612 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
20 ms |
340 KB |
Output is correct |
12 |
Correct |
36 ms |
512 KB |
Output is correct |
13 |
Correct |
65 ms |
696 KB |
Output is correct |
14 |
Correct |
86 ms |
804 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
3064 ms |
17764 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
223 ms |
29548 KB |
Output is correct |
3 |
Correct |
206 ms |
29360 KB |
Output is correct |
4 |
Correct |
190 ms |
29436 KB |
Output is correct |
5 |
Correct |
157 ms |
22240 KB |
Output is correct |
6 |
Correct |
82 ms |
6492 KB |
Output is correct |
7 |
Correct |
161 ms |
11708 KB |
Output is correct |
8 |
Correct |
181 ms |
26380 KB |
Output is correct |
9 |
Correct |
185 ms |
23472 KB |
Output is correct |
10 |
Correct |
71 ms |
6268 KB |
Output is correct |
11 |
Correct |
145 ms |
14988 KB |
Output is correct |
12 |
Correct |
217 ms |
29376 KB |
Output is correct |
13 |
Correct |
209 ms |
29364 KB |
Output is correct |
14 |
Correct |
188 ms |
29452 KB |
Output is correct |
15 |
Correct |
167 ms |
22204 KB |
Output is correct |
16 |
Correct |
89 ms |
5476 KB |
Output is correct |
17 |
Correct |
123 ms |
11844 KB |
Output is correct |
18 |
Correct |
180 ms |
29388 KB |
Output is correct |
19 |
Correct |
203 ms |
29352 KB |
Output is correct |
20 |
Correct |
197 ms |
29308 KB |
Output is correct |
21 |
Correct |
181 ms |
26368 KB |
Output is correct |
22 |
Correct |
215 ms |
23564 KB |
Output is correct |
23 |
Correct |
58 ms |
6236 KB |
Output is correct |
24 |
Correct |
133 ms |
15056 KB |
Output is correct |
25 |
Correct |
217 ms |
29432 KB |
Output is correct |
26 |
Correct |
201 ms |
29448 KB |
Output is correct |
27 |
Correct |
188 ms |
29352 KB |
Output is correct |
28 |
Correct |
174 ms |
22240 KB |
Output is correct |
29 |
Correct |
73 ms |
5444 KB |
Output is correct |
30 |
Correct |
127 ms |
11788 KB |
Output is correct |
31 |
Correct |
183 ms |
29428 KB |
Output is correct |
32 |
Correct |
202 ms |
29400 KB |
Output is correct |
33 |
Correct |
195 ms |
29384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
340 KB |
Output is correct |
2 |
Correct |
43 ms |
564 KB |
Output is correct |
3 |
Correct |
9 ms |
392 KB |
Output is correct |
4 |
Correct |
12 ms |
340 KB |
Output is correct |
5 |
Correct |
52 ms |
612 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
20 ms |
340 KB |
Output is correct |
12 |
Correct |
36 ms |
512 KB |
Output is correct |
13 |
Correct |
65 ms |
696 KB |
Output is correct |
14 |
Correct |
86 ms |
804 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Execution timed out |
3075 ms |
15372 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
340 KB |
Output is correct |
2 |
Correct |
43 ms |
564 KB |
Output is correct |
3 |
Correct |
9 ms |
392 KB |
Output is correct |
4 |
Correct |
12 ms |
340 KB |
Output is correct |
5 |
Correct |
52 ms |
612 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
20 ms |
340 KB |
Output is correct |
12 |
Correct |
36 ms |
512 KB |
Output is correct |
13 |
Correct |
65 ms |
696 KB |
Output is correct |
14 |
Correct |
86 ms |
804 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Execution timed out |
3075 ms |
15372 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |