이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define SZ(x) (int) (x).size()
#define F first
#define S second
const int N = 55;
int lx, ly, rx, ry, A[N][N], M[N][N], n, m; int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
void DFS(int x, int y) {
if (A[x][y]) return;
M[x][y] = 1;
for (int i = 0; i < 4; i++) {
int nx = dx[i] + x, ny = dy[i] + y;
if (nx < lx || nx > rx || ny < ly || ny > ry || A[nx][ny] || M[nx][ny]) continue;
DFS(nx, ny);
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C;
A[sr][sc] = 1;
for (int i = 0; i < M; i++) {
char c = S[i]; int d = 0;
if (c == 'N') d = 2;
if (c == 'W') d = 3;
if (c == 'E') d = 1;
if (c == 'S') d = 0;
sr += dx[d], sc += dy[d];
A[sr][sc] = 1;
}
}
int colour(int ar, int ac, int br, int bc) {
int ret = 0; lx = ar, ly = ac, rx = br, ry = bc;
for (int i = ac; i <= bc; i++) {
for (int j = ar; j <= br; j++) {
if (!M[j][i] && !A[j][i]) DFS(j, i), ret++;
}
}
for (int i = ac; i <= bc; i++)
for (int j = ar; j <= br; j++)
M[j][i] = 0;
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... |