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"
using namespace std;
int marc[55][55], n1, n2,m1,m2;
int di[4] = {0,0,-1,1};
int dj[4] = {-1,1,0,0};
void init(int R, int C, int sr, int sc, int m, char *s) {
marc[sr][sc] = 2;
for(int i = 0; i < m; i++){
if(s[i] == 'N')sr--;
else if(s[i] == 'S')sr++;
else if(s[i] == 'W')sc--;
else sc++;
marc[sr][sc] = 2;
}
}
void dfs(int i, int j){
marc[i][j] = 1;
for(int d = 0; d < 4; d++){
int ni = i + di[d], nj = j + dj[d];
if(ni < n1 || ni > n2 || nj < m1 || nj > m2 || marc[ni][nj])continue;
dfs(ni,nj);
}
}
int colour(int ar, int ac, int br, int bc) {
for(int i = ar; i <= br; i++)
for(int j = ac; j <= bc; j++)
if(marc[i][j] != 2)marc[i][j] = 0;
n1 = ar; n2 = br;
m1 = ac; m2 = bc;
int qtd = 0;
for(int i = ar; i <= br; i++)
for(int j = ac; j <= bc; j++)
if(marc[i][j] == 0){
qtd++;
dfs(i,j);
}
return qtd;
}
# | 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... |