#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;
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--;
}
if (valid(sr, 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 |
Incorrect |
144 ms |
4300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4172 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4172 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
4300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
4300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |