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 <bits/stdc++.h>
using namespace std;
//#define int long long
bool water[51][51];
bool vis[51][51];
int minx,miny,maxx,maxy;
void dfs(int x,int y){
if(x<minx or y<miny or x>maxx or y>maxy or vis[x][y] or water[x][y])return;
vis[x][y]=true;
dfs(x-1,y);
dfs(x,y-1);
dfs(x+1,y);
dfs(x,y+1);
}
void init(int32_t R, int32_t C, int32_t sr, int32_t sc, int32_t M, char *S) {
water[sr][sc]=true;
for(int i=0;i<M;i++){
if(S[i]=='N')sr--;
else if(S[i]=='S')sr++;
else if(S[i]=='E')sc++;
else if(S[i]=='W')sc--;
water[sr][sc]=true;
}
}
int32_t colour(int32_t ar, int32_t ac, int32_t br, int32_t bc) {
minx = ar;
miny = ac;
maxx = br;
maxy = bc;
int ans = 0;
for(auto&i:vis)for(bool&j:i)j=false;
for(int x=ar;x<=br;x++)for(int y=ac;y<=bc;y++)if(!vis[x][y] and !water[x][y]){ans++;dfs(x,y);}
return ans;
}
# | 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... |