이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include "rainbow.h"
const int n0 = 53;
int n, r, c, bad[n0][n0], used[n0][n0];
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
void dfs(int x, int y) {
if (x < 1 || x > r || y < 1 || y > c || bad[x][y] || used[x][y]) return;
used[x][y] = 1;
for (int i = 0; i < 4; i++)
dfs(x + dx[i], y + dy[i]);
}
void init(int R, int C, int sr, int sc, int M, char *S) {
r = R, c = C;
int x = sr, y = sc;
bad[x][y] = 1;
for (int i = 0; i < M; i++) {
if (S[i] == 'N') x--;
if (S[i] == 'S') x++;
if (S[i] == 'W') y--;
if (S[i] == 'E') y++;
bad[x][y] = 1;
}
}
int colour(int ar, int ac, int br, int bc) {
for (int i = 1; i <= r; i++)
for (int j = 1; j <= c; j++)
if (i < ar || i > br || j < ac || j > bc)
bad[i][j]++;
int res = 0;
memset(& used, 0, sizeof(used));
for (int i = 1; i <= r; i++)
for (int j = 1; j <= c; j++)
if (!used[i][j] && !bad[i][j])
dfs(i, j), res++;
for (int i = 1; i <= r; i++)
for (int j = 1; j <= c; j++)
if (i < ar || i > br || j < ac || j > bc)
bad[i][j]--;
return res;
}
# | 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... |