#include <bits/stdc++.h>
//#include "rainbow.h"
using namespace std;
#define ll long long
#define fi first
#define se second
ll inf = 1ll << 60;
int r, c, m, r0, c0, r1, c1, r2, c2;
char *s;
map<pair<int, int>, bool> is, is2, vis;
bool valid(int i, int j){
if (i > r2 or i < r1) return false;
if (j > c2 or j < c1) return false;
if (is[{i, j}]) return false;
return true;
}
void dfs(int i, int j){
vis[{i, j}] = true;
if (is2[{i + 1, j}] and !vis[{i + 1, j}]) dfs(i + 1, j);
if (is2[{i - 1, j}] and !vis[{i - 1, j}]) dfs(i - 1, j);
if (is2[{i, j + 1}] and !vis[{i, j + 1}]) dfs(i, j + 1);
if (is2[{i, j - 1}] and !vis[{i, j - 1}]) dfs(i, j - 1);
}
void init(int _r, int _c, int _r0, int _c0, int _m, char *_s){
r = _r, c = _c, m = _m, r0 = _r0, c0 = _c0, s = _s;
}
int colour(int _r1, int _c1, int _r2, int _c2){
is.clear();
is2.clear();
vis.clear();
r1 = _r1, c1 = _c1, r2 = _r2, c2 = _c2;
vector<pair<int, int>> a, b;
a.push_back({r0, c0});
int x = r0, y = c0;
for (int i = 0; i < m; i++){
if (s[i] == 'S') x++;
if (s[i] == 'N') x--;
if (s[i] == 'E') y++;
if (s[i] == 'W') y--;
a.push_back({x, y});
is[{x, y}] = true;
}
for (int i = r1; i < r2; i++){
for (int j = c1; j < c2; j++) if (!is[{i, j}]) b.push_back({i, j});
}
int ans = 0;
for (auto i : b) is2[i] = true;
for (auto i : b){
if (!vis[i]){
dfs(i.fi, i.se);
ans++;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
3104 ms |
663968 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |