이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
map<char, pair<int, int>> ds;
pair<int, int> moves[4] = {
{0, -1},
{0, 1},
{1, 0},
{-1, 0},
};
bool mark[51][51];
int x, y;
void init(int R, int C, int sr, int sc, int M, char *S) {
x=R; y=C;
ds['N'] = {-1, 0};
ds['S'] = {1, 0};
ds['E'] = {0, 1};
ds['W'] = {0, -1};
for (int i=0; i<=50; i++) mark[i][0] = true;
for (int i=0; i<=50; i++) mark[0][i] = true;
mark[sr][sc] = true;
// cout << sr << ' ' << sc << endl;
for (int i=0; i<M; i++) {
char c = S[i];
sr += ds[c].first;
sc += ds[c].second;
mark[sr][sc] = true;
// cout << sr << ' ' << sc << endl;
}
}
bool tmp[51][51];
int lar, lac, lbr, lbc;
void dfs(int i, int j) {
if (i < lar or j < lac or i > lbr or j > lbc or tmp[i][j]) return;
tmp[i][j] = true;
for (pair<int, int> d : moves) {
dfs(i + d.first, j + d.second);
}
}
int colour(int ar, int ac, int br, int bc) {
lar = ar; lac = ac; lbr = br; lbc = bc;
int cnt = 0;
for (int i=1; i<=50; i++) {
for (int j=1; j<=50; j++) {
tmp[i][j] = mark[i][j];
}
}
for (int r=ar; r<=br; r++) {
for (int c=ac; c<=bc; c++) {
if (!tmp[r][c]) {
cnt++;
dfs(r, c);
}
}
}
return cnt;
}
# | 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... |