#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>r;
int n,m;
vector<int>dx = {-1,0,1,0};
vector<int>dy = {0,1,0,-1};
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R,m = C;
r.resize(R,vector<int>(C,0));
--sr;--sc;
for (int i = 0;i<M;++i){
char x = *S + i;
r[sr][sc] = 1;
if (x == 'N'){
sr--;
}
else if (x == 'S'){
sr++;
}
else if (x == 'W'){
sc--;
}
else{
sc++;
}
}
}
int colour(int ar, int ac, int br, int bc) {
vector<vector<bool>>visited(n,vector<bool>(m,0));
int ans = 0;
function<void(int,int)>dfs = [&](int u,int v){
visited[u][v] = true;
for (int i = 0;i<4;++i){
int nx = u + dx[i];
int ny = v + dy[i];
if (nx >=ar - 1 && nx < br && ny >= ac - 1 && ny < bc && !visited[nx][ny]){
dfs(nx,ny);
}
}
};
for (int i = ar - 1;i<br;++i){
for (int j = ac - 1;j<bc;++j){
if (!visited[i][j]){
dfs(i,j);
ans++;
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |