# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
404238 |
2021-05-14T01:46:52 Z |
AlexRex0 |
Mecho (IOI09_mecho) |
C++14 |
|
332 ms |
6980 KB |
#include <bits/stdc++.h>
using namespace std;
int n, s, xini, yini, xfin, yfin;
bool visitado[802][802];
char a[802][802];
int abejas[802][802];
struct dato{
int x;
int y;
int tiempo;
};
int mov[4][2] = {{1,0}, {0,1}, {-1, 0}, {0, - 1}};
queue<dato> cola;
dato aux, nuevo;
void buscaA(){
while(!cola.empty()){
aux = cola.front();
cola.pop();
if(!visitado[aux.x][aux.y]){
if(aux.x > n || aux.x < 1 || aux.y > n || aux.y < 1 || a[aux.x][aux.y] == 'T' || a[aux.x][aux.y] == 'D'){
}else{
visitado[aux.x][aux.y] = true;
abejas[aux.x][aux.y] = aux.tiempo;
for(int i = 0; i < 4; ++i){
nuevo.tiempo = aux.tiempo + 1;
nuevo.x = aux.x + mov[i][0];
nuevo.y = aux.y + mov[i][1];
cola.push(nuevo);
}
}
}
}
}
struct oso{
int x;
int y;
int minutos;
int cont;
};
oso inicial, frenteO, nuevoO;
queue<oso> colaO;
bool visitadoOso[802][802];
bool valido(int t){
inicial.minutos = t;
inicial.x = xini;
inicial.y = yini;
inicial.cont = 0;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
visitadoOso[i][j] = false;
}
}
colaO.push(inicial);
while(!colaO.empty()){
frenteO = colaO.front();
colaO.pop();
if(!visitadoOso[frenteO.x][frenteO.y]){
if(frenteO.x > n || frenteO.x < 1 || frenteO.y > n || frenteO.y < 1 || a[frenteO.x][frenteO.y] == 'T'){
}else{
if(frenteO.minutos < abejas[frenteO.x][frenteO.y] || (frenteO.x == xfin && frenteO.y == yfin)){
visitadoOso[frenteO.x][frenteO.y] = true;
for(int i = 0; i < 4; ++i){
nuevoO.cont = frenteO.cont + 1;
nuevoO.minutos = frenteO.minutos;
nuevoO.x = frenteO.x + mov[i][0];
nuevoO.y = frenteO.y + mov[i][1];
if(nuevoO.cont > s){
nuevoO.cont = 0;
nuevoO.minutos++;
}
colaO.push(nuevoO);
}
}
}
}
}
if(visitadoOso[xfin][yfin]){
return true;
}
return false;
}
int bs(){
int inf = 0; int sup = n * n, medio, res = -1;
while(inf <= sup){
medio = (inf + sup) / 2;
if(valido(medio)){
res = medio;
inf = medio + 1;
}else{
sup = medio - 1;
}
}
return res;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> s;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
cin >> a[i][j];
if(a[i][j] == 'H'){
aux.x = i;
aux.y = j;
aux.tiempo = 0;
cola.push(aux);
}
if(a[i][j] == 'M'){
xini = i;
yini = j;
}
if(a[i][j] == 'D'){
xfin = i;
yfin = j;
}
}
}
buscaA();
cout << bs();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
194 ms |
5996 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Incorrect |
2 ms |
592 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
16 |
Correct |
1 ms |
460 KB |
Output is correct |
17 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
22 |
Correct |
1 ms |
460 KB |
Output is correct |
23 |
Incorrect |
1 ms |
588 KB |
Output isn't correct |
24 |
Correct |
1 ms |
588 KB |
Output is correct |
25 |
Incorrect |
1 ms |
588 KB |
Output isn't correct |
26 |
Correct |
1 ms |
588 KB |
Output is correct |
27 |
Incorrect |
1 ms |
716 KB |
Output isn't correct |
28 |
Correct |
1 ms |
716 KB |
Output is correct |
29 |
Incorrect |
2 ms |
740 KB |
Output isn't correct |
30 |
Correct |
2 ms |
716 KB |
Output is correct |
31 |
Incorrect |
2 ms |
716 KB |
Output isn't correct |
32 |
Correct |
1 ms |
716 KB |
Output is correct |
33 |
Incorrect |
10 ms |
2352 KB |
Output isn't correct |
34 |
Correct |
11 ms |
2356 KB |
Output is correct |
35 |
Correct |
48 ms |
2412 KB |
Output is correct |
36 |
Incorrect |
13 ms |
2672 KB |
Output isn't correct |
37 |
Correct |
14 ms |
2708 KB |
Output is correct |
38 |
Correct |
61 ms |
2740 KB |
Output is correct |
39 |
Incorrect |
15 ms |
2892 KB |
Output isn't correct |
40 |
Correct |
18 ms |
3020 KB |
Output is correct |
41 |
Correct |
85 ms |
3048 KB |
Output is correct |
42 |
Incorrect |
19 ms |
3284 KB |
Output isn't correct |
43 |
Correct |
21 ms |
3344 KB |
Output is correct |
44 |
Correct |
104 ms |
3336 KB |
Output is correct |
45 |
Incorrect |
22 ms |
3660 KB |
Output isn't correct |
46 |
Correct |
25 ms |
3632 KB |
Output is correct |
47 |
Correct |
117 ms |
3696 KB |
Output is correct |
48 |
Incorrect |
27 ms |
3916 KB |
Output isn't correct |
49 |
Correct |
29 ms |
3892 KB |
Output is correct |
50 |
Correct |
142 ms |
4036 KB |
Output is correct |
51 |
Incorrect |
30 ms |
4228 KB |
Output isn't correct |
52 |
Correct |
36 ms |
4344 KB |
Output is correct |
53 |
Correct |
186 ms |
4292 KB |
Output is correct |
54 |
Incorrect |
35 ms |
4636 KB |
Output isn't correct |
55 |
Correct |
39 ms |
4560 KB |
Output is correct |
56 |
Correct |
207 ms |
4836 KB |
Output is correct |
57 |
Incorrect |
41 ms |
4924 KB |
Output isn't correct |
58 |
Correct |
45 ms |
5004 KB |
Output is correct |
59 |
Correct |
243 ms |
5060 KB |
Output is correct |
60 |
Incorrect |
45 ms |
5316 KB |
Output isn't correct |
61 |
Correct |
50 ms |
5300 KB |
Output is correct |
62 |
Correct |
272 ms |
5404 KB |
Output is correct |
63 |
Incorrect |
228 ms |
5328 KB |
Output isn't correct |
64 |
Correct |
332 ms |
5372 KB |
Output is correct |
65 |
Incorrect |
255 ms |
5408 KB |
Output isn't correct |
66 |
Incorrect |
229 ms |
5256 KB |
Output isn't correct |
67 |
Incorrect |
242 ms |
5444 KB |
Output isn't correct |
68 |
Incorrect |
81 ms |
5420 KB |
Output isn't correct |
69 |
Correct |
77 ms |
5440 KB |
Output is correct |
70 |
Incorrect |
64 ms |
5416 KB |
Output isn't correct |
71 |
Incorrect |
54 ms |
5460 KB |
Output isn't correct |
72 |
Correct |
50 ms |
5404 KB |
Output is correct |
73 |
Correct |
72 ms |
6980 KB |
Output is correct |
74 |
Correct |
118 ms |
6928 KB |
Output is correct |
75 |
Incorrect |
148 ms |
6952 KB |
Output isn't correct |
76 |
Incorrect |
123 ms |
6916 KB |
Output isn't correct |
77 |
Incorrect |
126 ms |
6884 KB |
Output isn't correct |
78 |
Incorrect |
161 ms |
6740 KB |
Output isn't correct |
79 |
Correct |
101 ms |
6724 KB |
Output is correct |
80 |
Incorrect |
123 ms |
6804 KB |
Output isn't correct |
81 |
Incorrect |
157 ms |
6824 KB |
Output isn't correct |
82 |
Incorrect |
127 ms |
6844 KB |
Output isn't correct |
83 |
Incorrect |
179 ms |
6592 KB |
Output isn't correct |
84 |
Correct |
143 ms |
6432 KB |
Output is correct |
85 |
Incorrect |
144 ms |
6468 KB |
Output isn't correct |
86 |
Incorrect |
174 ms |
6604 KB |
Output isn't correct |
87 |
Correct |
156 ms |
6468 KB |
Output is correct |
88 |
Incorrect |
165 ms |
6376 KB |
Output isn't correct |
89 |
Correct |
168 ms |
6304 KB |
Output is correct |
90 |
Correct |
175 ms |
6196 KB |
Output is correct |
91 |
Correct |
171 ms |
6276 KB |
Output is correct |
92 |
Incorrect |
186 ms |
6180 KB |
Output isn't correct |