#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
bool on[55][55];
int R, C;
void init(int _R, int _C, int sr, int sc, int M, char *S) {
int i, j;
R = _R, C = _C;
for(i=1;i<=R;i++) {
for(j=1;j<=C;j++) on[i][j] = true;
}
on[sr][sc] = false;
for(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++;
on[sr][sc] = false;
}
}
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool in(int x, int y) {
return 1<=x&&x<=R&&1<=y&&y<=C;
}
bool vis[55][55];
int dfs(int x, int y) {
vis[x][y] = true;
for(int k = 0; k < 4; k++) {
int x2 = x + dx[k], y2 = y + dy[k];
if(in(x2, y2) && !vis[x2][y2] && on[x2][y2]) {
dfs(x2, y2);
}
}
return 1;
}
int colour(int ar, int ac, int br, int bc) {
int i, j;
for(i=1;i<=R;i++) {
for(j=1;j<=C;j++) {
if(i<ar||i>br||j<ac||j>bc) vis[i][j] = true;
else vis[i][j]= false;
}
}
int sum = 0;
for(i=ar;i<=br;i++) {
for(j=ac;j<=bc;j++) {
if(on[i][j]&&!vis[i][j]) {
sum += dfs(i, j);
}
}
}
return sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
11 ms |
468 KB |
Output is correct |
3 |
Correct |
15 ms |
444 KB |
Output is correct |
4 |
Correct |
15 ms |
452 KB |
Output is correct |
5 |
Correct |
7 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
14 ms |
424 KB |
Output is correct |
12 |
Correct |
12 ms |
408 KB |
Output is correct |
13 |
Correct |
9 ms |
380 KB |
Output is correct |
14 |
Correct |
6 ms |
316 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Runtime error |
1 ms |
724 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
11 ms |
468 KB |
Output is correct |
3 |
Correct |
15 ms |
444 KB |
Output is correct |
4 |
Correct |
15 ms |
452 KB |
Output is correct |
5 |
Correct |
7 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
14 ms |
424 KB |
Output is correct |
12 |
Correct |
12 ms |
408 KB |
Output is correct |
13 |
Correct |
9 ms |
380 KB |
Output is correct |
14 |
Correct |
6 ms |
316 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
304 KB |
Output is correct |
18 |
Runtime error |
3 ms |
852 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
11 ms |
468 KB |
Output is correct |
3 |
Correct |
15 ms |
444 KB |
Output is correct |
4 |
Correct |
15 ms |
452 KB |
Output is correct |
5 |
Correct |
7 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
14 ms |
424 KB |
Output is correct |
12 |
Correct |
12 ms |
408 KB |
Output is correct |
13 |
Correct |
9 ms |
380 KB |
Output is correct |
14 |
Correct |
6 ms |
316 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
304 KB |
Output is correct |
18 |
Runtime error |
3 ms |
852 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |