#include "rainbow.h"
#include "bits/stdc++.h"
using namespace std;
vector< vector<bool> > Grilla;
vector< vector<bool> > Visitados;
vector< vector<bool> > Cero;
void init(int R, int C, int sr, int sc, int M, char *S){
vector<bool> A(C, 0);
Grilla.assign(R, A);
Visitados.assign(R, A);
Cero.assign(R, A);
Grilla[sr - 1][sc - 1] = 1;
Visitados[sr - 1][sc - 1] = 1;
Cero[sr - 1][sc - 1] = 1;
for(int i = 0; i < M; i++){
switch(S[i]){
case 'N':
sr--;
break;
case 'S':
sr++;
break;
case 'E':
sc++;
break;
case 'W':
sc--;
}
Grilla[sr - 1][sc - 1] = 1;
Visitados[sr - 1][sc - 1] = 1;
Cero[sr - 1][sc - 1] = 1;
}
}
vector<int> Modificador_F = {-1, 0, 1, 0};
vector<int> Modificador_C = {0, 1, 0, -1};
void DFS(int Fila, int Columna, int Fila_mayor, int Fila_menor, int Columna_mayor, int Columna_menor){
Visitados[Fila][Columna] = 1;
//cout<<Fila + 1<<" "<<Columna + 1<<"\n";
for(int i = 0; i < 4; i++){
int Nueva_fila = Fila + Modificador_F[i];
int Nueva_columna = Columna + Modificador_C[i];
if(Nueva_fila >= Fila_menor and Nueva_fila <= Fila_mayor and Nueva_columna >= Columna_menor and Nueva_columna <= Columna_mayor and Visitados[Nueva_fila][Nueva_columna] == 0) DFS(Nueva_fila, Nueva_columna, Fila_mayor, Fila_menor, Columna_mayor, Columna_menor);
}
}
int colour(int ar, int ac, int br, int bc){
int Respuesta = 0;
for(int Fila = ar - 1; Fila < br; Fila++){
for(int Columna = ac - 1; Columna < bc; Columna++){
if(Visitados[Fila][Columna] == 0){
Respuesta++;
DFS(Fila, Columna, br - 1, ar - 1, bc - 1, ac - 1);
}
}
}
Visitados = Cero;
return Respuesta;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
3 |
Correct |
13 ms |
604 KB |
Output is correct |
4 |
Correct |
13 ms |
604 KB |
Output is correct |
5 |
Correct |
6 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
440 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
444 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
356 KB |
Output is correct |
11 |
Correct |
12 ms |
604 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Correct |
8 ms |
556 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
3042 ms |
22620 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
743 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
3 |
Correct |
13 ms |
604 KB |
Output is correct |
4 |
Correct |
13 ms |
604 KB |
Output is correct |
5 |
Correct |
6 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
440 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
444 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
356 KB |
Output is correct |
11 |
Correct |
12 ms |
604 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Correct |
8 ms |
556 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Execution timed out |
3030 ms |
9976 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
3 |
Correct |
13 ms |
604 KB |
Output is correct |
4 |
Correct |
13 ms |
604 KB |
Output is correct |
5 |
Correct |
6 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
440 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
444 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
356 KB |
Output is correct |
11 |
Correct |
12 ms |
604 KB |
Output is correct |
12 |
Correct |
10 ms |
344 KB |
Output is correct |
13 |
Correct |
8 ms |
556 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Execution timed out |
3030 ms |
9976 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |