This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
int n;int m;int sx;int sy;
string s;
int gr[60][60];
void init(int R, int C, int sr, int sc, int M, char *S) {
n=R;m=C;
gr[sr][sc]=1;
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++;}
    gr[sr][sc]=1;
}
}
int vis[60][60];
int dir[5]={0,1,0,-1,0};
int A;int B;int C;int D;
int ok(int x,int y){
if(x>=A&&x<=B&&y>=C&&y<=D){return 1;}
return 0;
}
void dfs(int nwx,int nwy){
vis[nwx][nwy]=1;
for(int i=0;i<4;i++){
    int vx=nwx+dir[i];int vy=nwy+dir[i+1];
    if(ok(vx,vy)&&vis[vx][vy]==0&&gr[vx][vy]==0){
        dfs(vx,vy);
    }
}
}
int colour(int ar, int ac, int br, int bc) {
A=ar;B=br;
C=ac;D=bc;
int ret=0;
for(int i=A;i<=B;i++){
    for(int j=C;j<=D;j++){
        if(vis[i][j]==0&&gr[i][j]==0){
            dfs(i,j);
            ret++;
        }
    }
}
    return ret;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |