#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000;
int v[MAXN][MAXN];
int marc[MAXN][MAXN];
int dx[]={0, -1, 0, 1};
int dy[]={1, 0, -1, 0};
int n, m;
void dfs(int ox, int oy) {
//printf("%d %d\n", ox, oy);
marc[ox][oy]=2;
for(int i=0; i<4; i++) {
int vx=ox+dx[i]; int vy=oy+dy[i];
//printf(" viz : %d %d\n", vx, vy);
if(vx<=0||vx>n) continue; if(vy<=0||vy>m) continue;
if(marc[vx][vy]!=1||v[vx][vy]) continue;
dfs(vx, vy);
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
int cx=sr, cy=sc; v[cx][cy]=1; n=R; m=C;
for(int i=0; i<M; i++) {
if(S[i]=='N') cx--;
if(S[i]=='S') cx++;
if(S[i]=='W') cy--;
if(S[i]=='E') cy++;
v[cx][cy]=1;
}
}
int colour(int ar, int ac, int br, int bc) {
for(int i=ar; i<=br; i++) for(int j=ac; j<=bc; j++) marc[i][j]=1;
int resp=0;
for(int i=ar; i<=br; i++) {
for(int j=ac; j<=bc; j++) {
if(marc[i][j]==2||v[i][j]) continue;
dfs(i, j); resp++;
}
}
for(int i=ar; i<=br; i++) for(int j=ac; j<=bc; j++) marc[i][j]=0;
return resp;
return 0;
}
Compilation message
rainbow.cpp: In function 'void dfs(int, int)':
rainbow.cpp:18:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(vx<=0||vx>n) continue; if(vy<=0||vy>m) continue;
^~
rainbow.cpp:18:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(vx<=0||vx>n) continue; if(vy<=0||vy>m) continue;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
13 ms |
868 KB |
Output is correct |
3 |
Correct |
29 ms |
868 KB |
Output is correct |
4 |
Correct |
23 ms |
984 KB |
Output is correct |
5 |
Correct |
12 ms |
984 KB |
Output is correct |
6 |
Correct |
4 ms |
984 KB |
Output is correct |
7 |
Correct |
3 ms |
984 KB |
Output is correct |
8 |
Correct |
3 ms |
984 KB |
Output is correct |
9 |
Correct |
3 ms |
984 KB |
Output is correct |
10 |
Correct |
2 ms |
984 KB |
Output is correct |
11 |
Correct |
18 ms |
1128 KB |
Output is correct |
12 |
Correct |
18 ms |
1128 KB |
Output is correct |
13 |
Correct |
16 ms |
1180 KB |
Output is correct |
14 |
Correct |
14 ms |
1180 KB |
Output is correct |
15 |
Correct |
2 ms |
1180 KB |
Output is correct |
16 |
Correct |
3 ms |
1180 KB |
Output is correct |
17 |
Correct |
2 ms |
1180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1180 KB |
Output is correct |
2 |
Correct |
2 ms |
1180 KB |
Output is correct |
3 |
Execution timed out |
3047 ms |
6196 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1180 KB |
Output is correct |
2 |
Runtime error |
5 ms |
6196 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
13 ms |
868 KB |
Output is correct |
3 |
Correct |
29 ms |
868 KB |
Output is correct |
4 |
Correct |
23 ms |
984 KB |
Output is correct |
5 |
Correct |
12 ms |
984 KB |
Output is correct |
6 |
Correct |
4 ms |
984 KB |
Output is correct |
7 |
Correct |
3 ms |
984 KB |
Output is correct |
8 |
Correct |
3 ms |
984 KB |
Output is correct |
9 |
Correct |
3 ms |
984 KB |
Output is correct |
10 |
Correct |
2 ms |
984 KB |
Output is correct |
11 |
Correct |
18 ms |
1128 KB |
Output is correct |
12 |
Correct |
18 ms |
1128 KB |
Output is correct |
13 |
Correct |
16 ms |
1180 KB |
Output is correct |
14 |
Correct |
14 ms |
1180 KB |
Output is correct |
15 |
Correct |
2 ms |
1180 KB |
Output is correct |
16 |
Correct |
3 ms |
1180 KB |
Output is correct |
17 |
Correct |
2 ms |
1180 KB |
Output is correct |
18 |
Runtime error |
11 ms |
7364 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
13 ms |
868 KB |
Output is correct |
3 |
Correct |
29 ms |
868 KB |
Output is correct |
4 |
Correct |
23 ms |
984 KB |
Output is correct |
5 |
Correct |
12 ms |
984 KB |
Output is correct |
6 |
Correct |
4 ms |
984 KB |
Output is correct |
7 |
Correct |
3 ms |
984 KB |
Output is correct |
8 |
Correct |
3 ms |
984 KB |
Output is correct |
9 |
Correct |
3 ms |
984 KB |
Output is correct |
10 |
Correct |
2 ms |
984 KB |
Output is correct |
11 |
Correct |
18 ms |
1128 KB |
Output is correct |
12 |
Correct |
18 ms |
1128 KB |
Output is correct |
13 |
Correct |
16 ms |
1180 KB |
Output is correct |
14 |
Correct |
14 ms |
1180 KB |
Output is correct |
15 |
Correct |
2 ms |
1180 KB |
Output is correct |
16 |
Correct |
3 ms |
1180 KB |
Output is correct |
17 |
Correct |
2 ms |
1180 KB |
Output is correct |
18 |
Runtime error |
11 ms |
7364 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |