#include "rainbow.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<bool> used[2009]; int H, W, minx = (1 << 30), miny = (1 << 30), maxx = 0, maxy = 0;
vector<int> A[4][2009], A2[2009], A3[2009], A4[2009];
void init(int R, int C, int sr, int sc, int M, char *S) {
H = R; W = C;
for (int i = 0; i <= H; i++) used[i].resize(W + 1, true);
for (int i = 0; i <= H; i++) { for (int j = 0; j < 4; j++) A[j][i].resize(W + 1, 0); }
int cx = sr, cy = sc; used[cx][cy] = false; minx = cx; miny = cy; maxx = cx; maxy = cy;
for (int i = 0; i < M; i++) {
if (S[i] == 'E') cy++;
if (S[i] == 'W') cy--;
if (S[i] == 'N') cx--;
if (S[i] == 'S') cx++;
used[cx][cy] = false;
minx = min(minx, cx); maxx = max(maxx, cx);
miny = min(miny, cy); maxy = max(maxy, cy);
}
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) { if (used[i][j] == true) A[0][i][j] = 1; }
}
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W - 1; j++) { if (used[i][j] == true && used[i][j + 1] == true) A[1][i][j] = 1; }
}
for (int i = 1; i <= H - 1; i++) {
for (int j = 1; j <= W; j++) { if (used[i][j] == true && used[i + 1][j] == true) A[2][i][j] = 1; }
}
for (int i = 1; i <= H - 1; i++) {
for (int j = 1; j <= W - 1; j++) { if (used[i][j] == true && used[i][j + 1] == true && used[i + 1][j] == true && used[i + 1][j + 1] == true) A[3][i][j] = 1; }
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j <= H; j++) {
for (int k = 1; k <= W; k++) A[i][j][k] += A[i][j][k - 1];
}
for (int j = 1; j <= H; j++) {
for (int k = 0; k <= W; k++) A[i][j][k] += A[i][j - 1][k];
}
}
}
int ranged(int ty, int px, int py, int qx, int qy) {
if (px > qx || py > qy) return 0;
return A[ty][px - 1][py - 1] + A[ty][qx][qy] - A[ty][px - 1][qy] - A[ty][qx][py - 1];
}
int colour(int ar, int ac, int br, int bc) {
int Z1 = ranged(0, ar, ac, br, bc);
int Z2 = ranged(1, ar, ac, br, bc - 1);
int Z3 = ranged(2, ar, ac, br - 1, bc);
int Z4 = ranged(3, ar, ac, br - 1, bc - 1);
int BONUS = 0; if (ar < minx && maxx < br && ac < miny && maxy < bc) BONUS = 1;
return (Z1 - Z2 - Z3 + Z4 + BONUS);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
740 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
3 ms |
768 KB |
Output is correct |
4 |
Correct |
4 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
2 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
896 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
3 ms |
768 KB |
Output is correct |
11 |
Correct |
4 ms |
768 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
0 ms |
768 KB |
Output is correct |
14 |
Correct |
4 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
768 KB |
Output is correct |
16 |
Correct |
3 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
768 KB |
Output is correct |
2 |
Correct |
2 ms |
768 KB |
Output is correct |
3 |
Correct |
118 ms |
11048 KB |
Output is correct |
4 |
Correct |
119 ms |
11012 KB |
Output is correct |
5 |
Correct |
117 ms |
11132 KB |
Output is correct |
6 |
Correct |
117 ms |
11004 KB |
Output is correct |
7 |
Correct |
106 ms |
11128 KB |
Output is correct |
8 |
Correct |
130 ms |
10988 KB |
Output is correct |
9 |
Correct |
118 ms |
11000 KB |
Output is correct |
10 |
Correct |
142 ms |
10992 KB |
Output is correct |
11 |
Correct |
127 ms |
11128 KB |
Output is correct |
12 |
Correct |
74 ms |
11000 KB |
Output is correct |
13 |
Correct |
88 ms |
11000 KB |
Output is correct |
14 |
Correct |
76 ms |
11008 KB |
Output is correct |
15 |
Correct |
96 ms |
11048 KB |
Output is correct |
16 |
Correct |
103 ms |
11000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Runtime error |
106 ms |
99860 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
740 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
3 ms |
768 KB |
Output is correct |
4 |
Correct |
4 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
2 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
896 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
3 ms |
768 KB |
Output is correct |
11 |
Correct |
4 ms |
768 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
0 ms |
768 KB |
Output is correct |
14 |
Correct |
4 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
768 KB |
Output is correct |
16 |
Correct |
3 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
768 KB |
Output is correct |
18 |
Correct |
145 ms |
17400 KB |
Output is correct |
19 |
Correct |
81 ms |
3064 KB |
Output is correct |
20 |
Correct |
62 ms |
1528 KB |
Output is correct |
21 |
Correct |
67 ms |
2060 KB |
Output is correct |
22 |
Correct |
79 ms |
3028 KB |
Output is correct |
23 |
Correct |
88 ms |
3100 KB |
Output is correct |
24 |
Correct |
65 ms |
1532 KB |
Output is correct |
25 |
Correct |
66 ms |
2120 KB |
Output is correct |
26 |
Correct |
83 ms |
3064 KB |
Output is correct |
27 |
Correct |
165 ms |
17616 KB |
Output is correct |
28 |
Correct |
138 ms |
17456 KB |
Output is correct |
29 |
Correct |
133 ms |
17416 KB |
Output is correct |
30 |
Correct |
149 ms |
17572 KB |
Output is correct |
31 |
Correct |
4 ms |
768 KB |
Output is correct |
32 |
Correct |
110 ms |
17400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
740 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
3 ms |
768 KB |
Output is correct |
4 |
Correct |
4 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
2 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
896 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
3 ms |
768 KB |
Output is correct |
11 |
Correct |
4 ms |
768 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
0 ms |
768 KB |
Output is correct |
14 |
Correct |
4 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
768 KB |
Output is correct |
16 |
Correct |
3 ms |
768 KB |
Output is correct |
17 |
Correct |
2 ms |
768 KB |
Output is correct |
18 |
Correct |
145 ms |
17400 KB |
Output is correct |
19 |
Correct |
81 ms |
3064 KB |
Output is correct |
20 |
Correct |
62 ms |
1528 KB |
Output is correct |
21 |
Correct |
67 ms |
2060 KB |
Output is correct |
22 |
Correct |
79 ms |
3028 KB |
Output is correct |
23 |
Correct |
88 ms |
3100 KB |
Output is correct |
24 |
Correct |
65 ms |
1532 KB |
Output is correct |
25 |
Correct |
66 ms |
2120 KB |
Output is correct |
26 |
Correct |
83 ms |
3064 KB |
Output is correct |
27 |
Correct |
165 ms |
17616 KB |
Output is correct |
28 |
Correct |
138 ms |
17456 KB |
Output is correct |
29 |
Correct |
133 ms |
17416 KB |
Output is correct |
30 |
Correct |
149 ms |
17572 KB |
Output is correct |
31 |
Correct |
4 ms |
768 KB |
Output is correct |
32 |
Correct |
110 ms |
17400 KB |
Output is correct |
33 |
Runtime error |
106 ms |
99860 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
34 |
Halted |
0 ms |
0 KB |
- |