#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) a.size()
#define pb push_back
#define vt vector
#define s second
#define f first
#define nl '\n'
using ll = long long;
using pii = pair<int, int>;
vt<pii> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int N = 1e3 + 5, mod = 1e9 + 7;
const int inf = 2e9;
double eps = 1e-6;
bool is[N][N], was[N][N];
int r, c;
int ar, br, ac, bc;
void init(int R, int C, int sr, int sc, int m, char *s) {
is[sr][sc] = 1;
r = R;
c = C;
for (int i = 0; i < m; i++) {
if (s[i] == 'N') sr--;
if (s[i] == 'S') sr++;
if (s[i] == 'W') sc--;
if (s[i] == 'E') sc++;
is[sr][sc] = 1;
}
}
bool ok(int x, int y) {
return x >= ar && x <= br && y >= ac && y <= bc;
}
void dfs(int x, int y) {
was[x][y] = 1;
for (auto v: dir) {
x += v.f;
y += v.s;
if (ok(x, y) && !is[x][y] && !was[x][y]) {
dfs(x, y);
}
x -= v.f;
y -= v.s;
}
}
int colour(int aR, int aC, int bR, int bC) {
ar = aR, ac = aC;
br = bR, bc = bC;
int cnt = 0;
for (int i = ar; i <= br; i++) {
for (int j = ac; j <= bc; j++) {
if (!is[i][j] && !was[i][j]) {
dfs(i, j);
cnt++;
}
}
}
for (int i = ar; i <= br; i++) {
for (int j = ac; j <= bc; j++) was[i][j] = 0;
}
return cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
452 KB |
Output is correct |
3 |
Correct |
13 ms |
452 KB |
Output is correct |
4 |
Correct |
14 ms |
560 KB |
Output is correct |
5 |
Correct |
5 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
224 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
11 ms |
468 KB |
Output is correct |
12 |
Correct |
9 ms |
512 KB |
Output is correct |
13 |
Correct |
7 ms |
468 KB |
Output is correct |
14 |
Correct |
3 ms |
456 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
312 KB |
Output is correct |
3 |
Execution timed out |
3048 ms |
9660 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 |
1 ms |
724 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
452 KB |
Output is correct |
3 |
Correct |
13 ms |
452 KB |
Output is correct |
4 |
Correct |
14 ms |
560 KB |
Output is correct |
5 |
Correct |
5 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
224 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
11 ms |
468 KB |
Output is correct |
12 |
Correct |
9 ms |
512 KB |
Output is correct |
13 |
Correct |
7 ms |
468 KB |
Output is correct |
14 |
Correct |
3 ms |
456 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
312 KB |
Output is correct |
18 |
Execution timed out |
3041 ms |
9564 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
452 KB |
Output is correct |
3 |
Correct |
13 ms |
452 KB |
Output is correct |
4 |
Correct |
14 ms |
560 KB |
Output is correct |
5 |
Correct |
5 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
224 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
11 ms |
468 KB |
Output is correct |
12 |
Correct |
9 ms |
512 KB |
Output is correct |
13 |
Correct |
7 ms |
468 KB |
Output is correct |
14 |
Correct |
3 ms |
456 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
312 KB |
Output is correct |
18 |
Execution timed out |
3041 ms |
9564 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |