#include "rainbow.h"
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iostream>
using namespace std;
const int MAX_N = 50;
typedef long long ll;
typedef pair<int, int> pii;
bool chk[MAX_N+1][MAX_N+1];
int R, C;
void init(int r, int c, int sr, int sc, int M, char *S) {
R = r; C = c;
chk[sr][sc] = true;
for(int i=0; i<M; i++){
if(S[i]=='N') sr--;
else if(S[i]=='E') sc++;
else if(S[i]=='W') sc--;
else sr++;
//cout<<sr<<" "<<sc<<endl;
chk[sr][sc] = true;
}
}
bool vst[MAX_N+1][MAX_N+1];
pii A, B;
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
void dfs(int x, int y){
if(x<A.first || x>B.first|| y<A.second || y>B.second) return;
if(vst[x][y] || chk[x][y]) return;
vst[x][y] = true;
for(int i=0; i<4; i++){
dfs(x+dx[i], y+dy[i]);
}
}
int colour(int ar, int ac, int br, int bc) {
A = {ar, ac}; B = {br, bc};
for(int i=ar; i<=br; i++){
for(int j=ac; j<=bc; j++){
vst[i][j] = false;
}
}
int ans = 0;
for(int i=ar; i<=br; i++){
for(int j=ac; j<=bc; j++){
if(!chk[i][j] && !vst[i][j]){
//cout<<i<<" "<<j<<endl;
ans++;
dfs(i, j);
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
23 ms |
384 KB |
Output is correct |
4 |
Correct |
17 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
440 KB |
Output is correct |
12 |
Correct |
15 ms |
384 KB |
Output is correct |
13 |
Correct |
13 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Runtime error |
2 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 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 |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
23 ms |
384 KB |
Output is correct |
4 |
Correct |
17 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
440 KB |
Output is correct |
12 |
Correct |
15 ms |
384 KB |
Output is correct |
13 |
Correct |
13 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Runtime error |
3 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
23 ms |
384 KB |
Output is correct |
4 |
Correct |
17 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
21 ms |
440 KB |
Output is correct |
12 |
Correct |
15 ms |
384 KB |
Output is correct |
13 |
Correct |
13 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Runtime error |
3 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |