#include "bits/stdc++.h"
#include "rainbow.h"
using namespace std;
vector<vector<bool>> ex;
int r, c;
void init(int R, int C, int sr, int sc, int M, char *S) {
r = R; c = C;
ex.assign(r + 1, vector<bool>(c + 1));
ex[sr][sc] = true;
for (int i = 0; i < M; i++) {
if (S[i] == 'N') sr--;
else if (S[i] == 'S') sr++;
else if (S[i] == 'W') sc--;
else sc++;
ex[sr][sc] = true;
}
}
int colour(int ar, int ac, int br, int bc) {
auto vis = ex;
int ans = 0;
// cout << '\t' << ar << ' ' << ac << ' ' << br << ' ' << bc << endl;
for (int x = ar; x <= br; x++) {
for (int y = ac; y <= bc; y++) {
if (vis[x][y]) continue;
queue<pair<int, int>> q;
q.push({x, y});
vis[x][y] = true;
ans++;
vector<pair<int, int>> a = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
while (!q.empty()) {
auto [qx, qy] = q.front();
// cout << '\t' << qx << ' ' << qy << endl;
q.pop();
for (auto [dx, dy]: a) {
qx += dx; qy += dy;
if (qx >= ar and qx <= br and qy >= ac and qy <= bc and !vis[qx][qy]) {
vis[qx][qy] = true;
q.push({qx, qy});
}
qx -= dx; qy -= dy;
}
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
340 KB |
Output is correct |
2 |
Correct |
19 ms |
320 KB |
Output is correct |
3 |
Correct |
32 ms |
324 KB |
Output is correct |
4 |
Correct |
29 ms |
344 KB |
Output is correct |
5 |
Correct |
18 ms |
352 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
27 ms |
344 KB |
Output is correct |
12 |
Correct |
28 ms |
352 KB |
Output is correct |
13 |
Correct |
22 ms |
344 KB |
Output is correct |
14 |
Correct |
29 ms |
340 KB |
Output is correct |
15 |
Correct |
0 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 |
3072 ms |
752 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
389 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
340 KB |
Output is correct |
2 |
Correct |
19 ms |
320 KB |
Output is correct |
3 |
Correct |
32 ms |
324 KB |
Output is correct |
4 |
Correct |
29 ms |
344 KB |
Output is correct |
5 |
Correct |
18 ms |
352 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
27 ms |
344 KB |
Output is correct |
12 |
Correct |
28 ms |
352 KB |
Output is correct |
13 |
Correct |
22 ms |
344 KB |
Output is correct |
14 |
Correct |
29 ms |
340 KB |
Output is correct |
15 |
Correct |
0 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 |
3053 ms |
1128 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
340 KB |
Output is correct |
2 |
Correct |
19 ms |
320 KB |
Output is correct |
3 |
Correct |
32 ms |
324 KB |
Output is correct |
4 |
Correct |
29 ms |
344 KB |
Output is correct |
5 |
Correct |
18 ms |
352 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
27 ms |
344 KB |
Output is correct |
12 |
Correct |
28 ms |
352 KB |
Output is correct |
13 |
Correct |
22 ms |
344 KB |
Output is correct |
14 |
Correct |
29 ms |
340 KB |
Output is correct |
15 |
Correct |
0 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 |
3053 ms |
1128 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |