-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path479_Sin_radar.cpp
70 lines (62 loc) · 1.25 KB
/
479_Sin_radar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Usuario de Acepta el reto: jjjjjjjp022
#include <iostream>
#include <vector>
using namespace std;
bool dentro(int filas, int columnas, int f, int c)
{
return f>=0 && c>=0 && filas>f && columnas>c;
}
pair <int, int> convert(string word)
{
if(word == "ARRIBA")
return {-1,0};
else if(word == "IZQUIERDA")
return {0,-1};
else if(word == "DERECHA")
return {0,1};
else if(word == "ABAJO")
return {1,0};
else
{
cout << "ERROR";
return {0,0};
}
}
int main(){
int filas, columnas;//Lectura
cin >> filas >> columnas;
while(filas!=0 || columnas != 0)
{
vector <string> v;//Lectura del mapa
for(int i = 0; i < filas; i++)
{
string aux;
cin >> aux;
v.push_back(aux);
}
//Lectura de las consultas
int n;
cin >> n;
while(n--)
{
int f, c;
string dir;
cin >> f >> c >> dir;//Lectura del caso
f--;
c--;
//bool encontrado = false;
int n = 0;
while(dentro(filas, columnas, f+n*convert(dir).first, c+n*convert(dir).second) && v[f+n*convert(dir).first][c+n*convert(dir).second] == '.')
{
n++;
}
if(dentro(filas, columnas, f+n*convert(dir).first, c+n*convert(dir).second))
cout << n;
else
cout << "NINGUNO";
cout << "\n";
}
cout << "---\n";
cin >> filas >> columnas;
}
}