#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S&&...y){cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define bug(...)
#endif // BALBIT
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#ifndef BALBIT
#include "rainbow.h"
#endif
int n,m;
vector<pii> pts;
bool H(pii &p) {
return *lower_bound(ALL(pts), p) == p;
}
const int maxn = 3e5+5;
bool g[60][60];
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C;
pts.pb({sr, sc});
g[sr-1][sc-1] = 1;
for (int i = 0; i<M; ++i) {
if (S[i] == 'N') {
--sr;
}
if (S[i] == 'S') {
++sr;
}
if (S[i] == 'E') {
++sc;
}
if (S[i] == 'W') {
--sc;
}
g[sr-1][sc-1] = 1;
}
// sort(ALL(pts));
// pts.resize(unique(ALL(pts)) - pts.begin());
}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int r1, c1, r2, c2;
map<pii, int> dir;
auto cmp = [&](int r, int c) {return r >= r1 && r <= r2 && c >= c1 && c <= c2;};
bool seen[60][60];
void dfs(int i, int j) {
if (!cmp(i,j) || g[i][j] || seen[i][j]) return;
seen[i][j] = 1;
for (int I = 0; I<4; ++I) {
dfs(i+dx[I], j + dy[I]);
}
}
int colour(int R1, int C1, int R2, int C2) {
tie(r1,c1,r2,c2) = tie(R1,C1,R2,C2);
-- r1; -- c1; --r2; --c2;
memset(seen, 0, sizeof seen);
int re = 0;
for (int i = r1; i<= r2; ++i) {
for (int j = c1; j<=c2; ++j) {
if (!g[i][j] && !seen[i][j]) {
dfs(i,j); re++;
}
}
}
return re;
}
#ifdef BALBIT
signed main(){
IOS();
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
16 ms |
384 KB |
Output is correct |
4 |
Correct |
16 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
388 KB |
Output is correct |
13 |
Correct |
9 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Runtime error |
4 ms |
2944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
16 ms |
384 KB |
Output is correct |
4 |
Correct |
16 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
388 KB |
Output is correct |
13 |
Correct |
9 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Execution timed out |
3069 ms |
2436 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
16 ms |
384 KB |
Output is correct |
4 |
Correct |
16 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
388 KB |
Output is correct |
13 |
Correct |
9 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Execution timed out |
3069 ms |
2436 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |