#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define SZ(x) (int) (x).size()
#define F first
#define S second
const int N = 55;
int lx, ly, rx, ry, A[N][N], M[N][N], n, m; int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
void DFS(int x, int y) {
if (A[x][y]) return;
M[x][y] = 1;
for (int i = 0; i < 4; i++) {
int nx = dx[i] + x, ny = dy[i] + y;
if (nx < lx || nx > rx || ny < ly || ny > ry || A[nx][ny] || M[nx][ny]) continue;
DFS(nx, ny);
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C;
A[sr][sc] = 1;
for (int i = 0; i < M; i++) {
char c = S[i]; int d = 0;
if (c == 'N') d = 2;
if (c == 'W') d = 3;
if (c == 'E') d = 1;
if (c == 'S') d = 0;
sr += dx[d], sc += dy[d];
A[sr][sc] = 1;
}
}
int colour(int ar, int ac, int br, int bc) {
int ret = 0; lx = ar, ly = ac, rx = br, ry = bc;
for (int i = ac; i <= bc; i++) {
for (int j = ar; j <= br; j++) {
if (!M[j][i] && !A[j][i]) DFS(j, i), ret++;
}
}
for (int i = ac; i <= bc; i++)
for (int j = ar; j <= br; j++)
M[j][i] = 0;
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
18 ms |
492 KB |
Output is correct |
4 |
Correct |
17 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
19 ms |
492 KB |
Output is correct |
12 |
Correct |
13 ms |
620 KB |
Output is correct |
13 |
Correct |
10 ms |
492 KB |
Output is correct |
14 |
Correct |
5 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
380 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Runtime error |
2 ms |
1132 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
380 KB |
Output is correct |
2 |
Runtime error |
1 ms |
748 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
18 ms |
492 KB |
Output is correct |
4 |
Correct |
17 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
19 ms |
492 KB |
Output is correct |
12 |
Correct |
13 ms |
620 KB |
Output is correct |
13 |
Correct |
10 ms |
492 KB |
Output is correct |
14 |
Correct |
5 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
380 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Runtime error |
2 ms |
1132 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
364 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
18 ms |
492 KB |
Output is correct |
4 |
Correct |
17 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
19 ms |
492 KB |
Output is correct |
12 |
Correct |
13 ms |
620 KB |
Output is correct |
13 |
Correct |
10 ms |
492 KB |
Output is correct |
14 |
Correct |
5 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
380 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Runtime error |
2 ms |
1132 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |