#include <iostream>
#include "rainbow.h"
#define FOR(i,l,r,d) for(int i=(l); i<=(r); i+=(d))
int grid[51][51];
bool vis[51][51];
const int dx[4] = {1,-1,0,0};
const int dy[4] = {0,0,1,-1};
void init(int R, int C, int sr, int sc, int M, char *S) {
/// 0=land 1=river
FOR(i,1,R,1){
FOR(j,1,C,1){
grid[i][j] = 0;
}
}
grid[sr][sc] = 1;
int rptr=sr, cptr=sc;
FOR(i,0,M-1,1){
if(S[i]=='E') cptr++;
if(S[i]=='W') cptr--;
if(S[i]=='N') rptr++;
if(S[i]=='S') rptr--;
grid[rptr][cptr] = 1;
}
}
void dfs(int ar, int ac, int br, int bc, int cr, int cc){
vis[cr][cc] = 1;
FOR(i,0,3,1){
int nr = cr + dx[i];
int nc = cc + dy[i];
if(ar<=nr and nr<=br and ac<=nc and nc<=bc and grid[nr][nc]==0 and vis[nr][nc]==0){
dfs(ar, ac, br, bc, nr, nc);
}
}
}
int colour(int ar, int ac, int br, int bc) {
FOR(i,ar,br,1){
FOR(j,ac,bc,1){
vis[i][j] = 0;
}
}
int ret = 0;
FOR(i,ar,br,1){
FOR(j,ac,bc,1){
if(grid[i][j]==0 and vis[i][j]==0){
dfs(ar, ac, br, bc, i, j);
ret++;
}
}
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
2 ms |
716 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |