#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define double long double
using pii = pair<int, int>;
template<typename T>
using prior = std::priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = std::priority_queue<T>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false), cin.tie(0)
const int maxn = 50 + 5;
int arr[maxn][maxn], vis[maxn][maxn];
void dfs(int nr, int nc, int ar, int ac, int br, int bc) {
if (nr < ar or br < nr) return;
if (nc < ac or bc < nc) return;
if (vis[nr][nc] or arr[nr][nc]) return;
vis[nr][nc] = 1;
dfs(nr + 1, nc, ar, ac, br, bc);
dfs(nr - 1, nc, ar, ac, br, bc);
dfs(nr, nc + 1, ar, ac, br, bc);
dfs(nr, nc - 1, ar, ac, br, bc);
}
void init(int R, int C, int sr, int sc, int M, char *S) {
arr[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;
arr[sr][sc] = 1;
}
/*
for (int i = 1; i <= R; ++i) {
for (int j = 1; j <= C; ++j) {
cout << arr[i][j];
}
cout << "\n";
}
*/
}
int colour(int ar, int ac, int br, int bc) {
int cnt = 0;
memset(vis, 0x00, sizeof(vis));
for (int i = ar; i <= br; ++i) {
for (int j = ac; j <= bc; ++j) {
if (!vis[i][j] and !arr[i][j]) {
++cnt, dfs(i, j, ar, ac, br, bc);
}
}
}
return cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
512 KB |
Output is correct |
4 |
Correct |
21 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
512 KB |
Output is correct |
12 |
Correct |
14 ms |
512 KB |
Output is correct |
13 |
Correct |
10 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
256 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
512 KB |
Output is correct |
4 |
Correct |
21 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
512 KB |
Output is correct |
12 |
Correct |
14 ms |
512 KB |
Output is correct |
13 |
Correct |
10 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
256 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Runtime error |
2 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
21 ms |
512 KB |
Output is correct |
4 |
Correct |
21 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
16 ms |
512 KB |
Output is correct |
12 |
Correct |
14 ms |
512 KB |
Output is correct |
13 |
Correct |
10 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
256 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Runtime error |
2 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |