#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1002;
int a[N][N], vis[N][N], done[N][N], u, l, d, r;
array<int, 4> di = {0, 0, 1, -1};
array<int, 4> dj = {1, -1, 0, 0};
bool valid(int i, int j) {
return (u <= i && i <= d && l <= j && j <= r && !vis[i][j] && !done[i][j]);
}
void dfs(int i, int j) {
done[i][j] = 1;
for (int k = 0; k < 4; k++) {
int ni = i + di[k];
int nj = j + dj[k];
if (valid(ni, nj)) {
dfs(ni, nj);
}
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
u = 1; d = R;
l = 1; r = C;
vis[sr][sc] = 1;
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--;
}
vis[sr][sc] = 1;
}
}
int colour(int ar, int ac, int br, int bc) {
u = ar; d = br;
l = ac; r = bc;
int ans = 0;
for (int i = u; i <= d; i++) {
for (int j = l; j <= r; j++) {
if (!vis[i][j] && !done[i][j]) {
dfs(i, j);
ans++;
}
}
}
memset(done, 0, sizeof done);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
4300 KB |
Output is correct |
2 |
Correct |
170 ms |
4456 KB |
Output is correct |
3 |
Correct |
155 ms |
4556 KB |
Output is correct |
4 |
Correct |
157 ms |
4548 KB |
Output is correct |
5 |
Correct |
152 ms |
4540 KB |
Output is correct |
6 |
Correct |
4 ms |
4172 KB |
Output is correct |
7 |
Correct |
4 ms |
4172 KB |
Output is correct |
8 |
Correct |
3 ms |
4172 KB |
Output is correct |
9 |
Correct |
3 ms |
4172 KB |
Output is correct |
10 |
Correct |
3 ms |
4172 KB |
Output is correct |
11 |
Correct |
160 ms |
4428 KB |
Output is correct |
12 |
Correct |
155 ms |
4512 KB |
Output is correct |
13 |
Correct |
152 ms |
4532 KB |
Output is correct |
14 |
Correct |
143 ms |
4452 KB |
Output is correct |
15 |
Correct |
2 ms |
4172 KB |
Output is correct |
16 |
Correct |
4 ms |
4172 KB |
Output is correct |
17 |
Correct |
4 ms |
4172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4172 KB |
Output is correct |
2 |
Correct |
4 ms |
4172 KB |
Output is correct |
3 |
Execution timed out |
3085 ms |
13276 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4172 KB |
Output is correct |
2 |
Runtime error |
2 ms |
588 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
4300 KB |
Output is correct |
2 |
Correct |
170 ms |
4456 KB |
Output is correct |
3 |
Correct |
155 ms |
4556 KB |
Output is correct |
4 |
Correct |
157 ms |
4548 KB |
Output is correct |
5 |
Correct |
152 ms |
4540 KB |
Output is correct |
6 |
Correct |
4 ms |
4172 KB |
Output is correct |
7 |
Correct |
4 ms |
4172 KB |
Output is correct |
8 |
Correct |
3 ms |
4172 KB |
Output is correct |
9 |
Correct |
3 ms |
4172 KB |
Output is correct |
10 |
Correct |
3 ms |
4172 KB |
Output is correct |
11 |
Correct |
160 ms |
4428 KB |
Output is correct |
12 |
Correct |
155 ms |
4512 KB |
Output is correct |
13 |
Correct |
152 ms |
4532 KB |
Output is correct |
14 |
Correct |
143 ms |
4452 KB |
Output is correct |
15 |
Correct |
2 ms |
4172 KB |
Output is correct |
16 |
Correct |
4 ms |
4172 KB |
Output is correct |
17 |
Correct |
4 ms |
4172 KB |
Output is correct |
18 |
Execution timed out |
3082 ms |
15376 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
4300 KB |
Output is correct |
2 |
Correct |
170 ms |
4456 KB |
Output is correct |
3 |
Correct |
155 ms |
4556 KB |
Output is correct |
4 |
Correct |
157 ms |
4548 KB |
Output is correct |
5 |
Correct |
152 ms |
4540 KB |
Output is correct |
6 |
Correct |
4 ms |
4172 KB |
Output is correct |
7 |
Correct |
4 ms |
4172 KB |
Output is correct |
8 |
Correct |
3 ms |
4172 KB |
Output is correct |
9 |
Correct |
3 ms |
4172 KB |
Output is correct |
10 |
Correct |
3 ms |
4172 KB |
Output is correct |
11 |
Correct |
160 ms |
4428 KB |
Output is correct |
12 |
Correct |
155 ms |
4512 KB |
Output is correct |
13 |
Correct |
152 ms |
4532 KB |
Output is correct |
14 |
Correct |
143 ms |
4452 KB |
Output is correct |
15 |
Correct |
2 ms |
4172 KB |
Output is correct |
16 |
Correct |
4 ms |
4172 KB |
Output is correct |
17 |
Correct |
4 ms |
4172 KB |
Output is correct |
18 |
Execution timed out |
3082 ms |
15376 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |