#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>r;
int n,m;
vector<int>dx = {-1,0,1,0};
vector<int>dy = {0,1,0,-1};
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R,m = C;
r.resize(R,vector<int>(C,0));
--sr;--sc;
for (int i = 0;i<M;++i){
char x = S[i];
r[sr][sc] = 1;
if (x == 'N'){
sr--;
}
else if (x == 'S'){
sr++;
}
else if (x == 'W'){
sc--;
}
else{
sc++;
}
}
r[sr][sc] = 1;
}
int colour(int ar, int ac, int br, int bc) {
vector<vector<bool>>visited(n,vector<bool>(m,0));
int ans = 0;
function<void(int,int)>dfs = [&](int u,int v){
visited[u][v] = true;
for (int i = 0;i<4;++i){
int nx = u + dx[i];
int ny = v + dy[i];
if (nx >=ar - 1 && nx < br && ny >= ac - 1 && ny < bc && !visited[nx][ny] && !r[nx][ny]){
dfs(nx,ny);
}
}
};
for (int i = ar - 1;i<br;++i){
for (int j = ac - 1;j<bc;++j){
if (!visited[i][j] && !r[i][j]){
dfs(i,j);
ans++;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
212 KB |
Output is correct |
2 |
Correct |
19 ms |
372 KB |
Output is correct |
3 |
Correct |
38 ms |
492 KB |
Output is correct |
4 |
Correct |
36 ms |
480 KB |
Output is correct |
5 |
Correct |
19 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
29 ms |
448 KB |
Output is correct |
12 |
Correct |
26 ms |
448 KB |
Output is correct |
13 |
Correct |
21 ms |
416 KB |
Output is correct |
14 |
Correct |
16 ms |
340 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 |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
3062 ms |
23980 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 |
438 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
212 KB |
Output is correct |
2 |
Correct |
19 ms |
372 KB |
Output is correct |
3 |
Correct |
38 ms |
492 KB |
Output is correct |
4 |
Correct |
36 ms |
480 KB |
Output is correct |
5 |
Correct |
19 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
29 ms |
448 KB |
Output is correct |
12 |
Correct |
26 ms |
448 KB |
Output is correct |
13 |
Correct |
21 ms |
416 KB |
Output is correct |
14 |
Correct |
16 ms |
340 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 |
212 KB |
Output is correct |
18 |
Execution timed out |
3075 ms |
13440 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
212 KB |
Output is correct |
2 |
Correct |
19 ms |
372 KB |
Output is correct |
3 |
Correct |
38 ms |
492 KB |
Output is correct |
4 |
Correct |
36 ms |
480 KB |
Output is correct |
5 |
Correct |
19 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
29 ms |
448 KB |
Output is correct |
12 |
Correct |
26 ms |
448 KB |
Output is correct |
13 |
Correct |
21 ms |
416 KB |
Output is correct |
14 |
Correct |
16 ms |
340 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 |
212 KB |
Output is correct |
18 |
Execution timed out |
3075 ms |
13440 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |