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 "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
int a[55][55], vis[55][55];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
void ffill (int i, int j, int ar, int ac, int br, int bc) {
if (a[i][j]) return;
if (vis[i][j]) return;
vis[i][j] = 1;
// cerr << i << ' ' << j << endl;
for (int d = 0; d < 4; d++) {
int ni = i+dx[d], nj = j+dy[d];
if (ni < ar or ni > br or nj < ac or nj > bc) continue;
if (vis[ni][nj]) continue;
if (a[ni][nj]) continue;
ffill(ni, nj, ar, ac, br, bc);
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
a[sr][sc] = 1;
for (int i = 0; i < M; i++) {
if (S[i] == 'N') sr--;
if (S[i] == 'S') sr++;
if (S[i] == 'W') sc--;
if (S[i] == 'E') sc++;
a[sr][sc] = 1;
}
// for (int i = 1; i <= R; i++) {
// for (int j = 1; j <= C; j++) {
// cerr << a[i][j] << ' ';
// } cerr << endl;
// }
}
int colour(int ar, int ac, int br, int bc) {
int cnt = 0;
memset(vis, 0, sizeof vis);
for (int i = ar; i <= br; i++) {
for (int j = ac; j <= bc; j++) {
if (vis[i][j]) continue;
if (a[i][j]) continue;
ffill(i, j, ar, ac, br, bc);
// cerr << "fill " << ' ' << i << ' ' << j << endl;
cnt++;
}
}
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... |