이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
const int maxn = 60;
bool mat[maxn][maxn];
int l[] = {-1, 1, 0, 0};
int c[] = {0, 0, -1, 1};
int n, m, pi, pj, mark[maxn][maxn];
int num=0;
int li, lj, ri, rj;
void dfs(int i, int j){
for(int k=0; k<4; k++){
int i2 = i+l[k], j2 = j+c[k];
if(i2 < li || i2 > ri || j2 < lj || j2 > rj || mat[i2][j2] || mark[i2][j2]) continue;
mark[i2][j2] = mark[i][j];
dfs(i2, j2);
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C;
pi = sr, pj = sc;
mat[sr][sc] = 1;
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 if(S[i] == 'E') ++sc;
mat[sr][sc] = 1;
}
}
int colour(int ar, int ac, int br, int bc) {
num = 0;
li = ar, lj = ac, ri = br, rj = bc;
for(int i=li;i<=ri;i++){
for(int j=lj;j<=rj;j++){
mark[i][j] = 0;
}
}
for(int i=li;i<=ri;i++){
for(int j=lj;j<=rj;j++){
if(mark[i][j] || mat[i][j]) continue;
mark[i][j] = ++num;
dfs(i, j);
}
}
return num;
}
# | 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... |