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>
#include "rainbow.h"
#define x first
#define y second
#define pb push_back
#define sz(v) (int)v.size()
using namespace std;
const int N=1e3+11;
const int dx[4]={0,0,-1,1};
const int dy[4]={1,-1,0,0};
int n,m;
int x,y;
string s;
bool used[N][N];
void init(int R, int C, int sr, int sc, int M, char *S) {
n=R;
m=C;
x=sr,y=sc;
s=S;
}
void dfs(int r,int c){
used[r][c]=1;
for(int i=0;i<4;i++){
int nx=x+dx[i],ny=y+dy[i];
if(used[nx][ny])continue;
dfs(nx,ny);
}
}
int colour(int ar, int ac, int br, int bc) {
if(max(n,m)<=50){
int ans=0;
for(int i=0;i<=n+1;i++){
for(int j=0;j<=n+1;j++){
if(ar<=i&&i<=br&&ac<=j&&j<=bc){
used[i][j]=0;
continue;
}
used[i][j]=1;
}
}
int sr=x,sc=y;
for(int i=0;i<sz(s);i++){
used[sr][sc]=1;
if(s[i]=='N')sr--;
if(s[i]=='S')sr++;
if(s[i]=='W')sc--;
if(s[i]=='E')sc++;
}
for(int i=ar;i<=br;i++){
for(int j=ac;j<=bc;j++){
if(!used[i][j]){
dfs(i,j);
ans++;
}
}
}
return ans;
}
}
Compilation message (stderr)
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |