#include<bits/stdc++.h>
#ifndef LOCAL
#include "rainbow.h"
#endif
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
using namespace std;
const int N = 1e5 + 10;
const int dx[] = {- 1, 0, 0, 1};
const int dy[] = {0, - 1, 1, 0};
int n, m, q;
int len, x, y;
char s[N];
bool un_go[60][60];
bool visited[60][60];
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R; m = C; x = sr; y = sc; len = M;
for(int i = 0; i < n; ++ i) s[i] = S[i];
un_go[x][y] = true;
for(int i = 0; i < len; ++ i) {
if(s[i] == 'N') -- x;
else if(s[i] == 'S') ++ x;
else if(s[i] == 'E') ++ y;
else -- y;
un_go[x][y] = true;
}
}
int colour(int ar, int ac, int br, int bc) {
int up = ar, le = ac, down = br, ri = bc;
int res = 0;
memset(visited, false, sizeof(visited));
for(int i = up; i <= down; ++ i) {
for(int j = le; j <= ri; ++ j) {
if(un_go[i][j] || visited[i][j]) continue;
auto inside = [&] (int x, int y) -> bool {
return (up <= x && x <= down && le <= y && y <= ri && !visited[x][y] && !un_go[x][y]);
};
++ res;
queue<pair<int, int>> q = {};
visited[i][j] = true; q.push(make_pair(i, j));
while(!q.empty()) {
auto [u, v] = q.front(); q.pop();
for(int k = 0; k < 4; ++ k) {
int r = u + dx[k], c = v + dy[k];
if(!inside(r, c)) continue;
visited[r][c] = true;
q.push(make_pair(r, c));
}
}
}
}
return res;
}
/// Code by vuavisao
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |