# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
912786 |
2024-01-19T22:29:44 Z |
Glauco |
Mecho (IOI09_mecho) |
C++17 |
|
207 ms |
5392 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, s; cin >> n >> s;
vector<vector<char>> g(n, vector<char>(n));
for(auto &i : g) for(auto &j : i) cin >> j;
queue<array<int, 3>> q;
pair<int, int> start;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
if(g[i][j] == 'M') start = {i, j};
if(g[i][j] == 'H') q.push({i, j, 0});
}
vector<vector<int>> free(n, vector<int>(n, 1e9));
while(!q.empty()){
auto [x, y, d] = q.front(); q.pop();
if(x < 0 || y < 0 || x >= n || y >= n) continue;
if(g[x][y] != 'H' && g[x][y] != 'G') continue;
if(free[x][y] != 1e9) continue;
free[x][y] = d;
q.push({x+1, y, d+1});
q.push({x-1, y, d+1});
q.push({x, y+1, d+1});
q.push({x, y-1, d+1});
}
int l = -1, r = 1e8;
while(l < r-1){
int m = (l+r)/2;
bool ok = 0;
vector<vector<bool>> vis(n, vector<bool>(n));
queue<array<int, 4>> b; b.push({start.first, start.second, m, s});
while(!b.empty()){
auto [x, y, d, st] = b.front(); b.pop();
if(x < 0 || y < 0 || x >= n || y >= n) continue;
if(st == 0){
st = s;
d++;
}
if(vis[x][y]) continue; vis[x][y] = 1;
if(g[x][y] == 'T') continue;
if(free[x][y] <= d) continue;
if(g[x][y] == 'D'){
ok = 1;
break;
}
b.push({x+1, y, d, st-1});
b.push({x-1, y, d, st-1});
b.push({x, y+1, d, st-1});
b.push({x, y-1, d, st-1});
}
if(ok) l = m;
else r = m;
}
cout << -1;
}
Compilation message
mecho.cpp: In function 'int main()':
mecho.cpp:48:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
48 | if(vis[x][y]) continue; vis[x][y] = 1;
| ^~
mecho.cpp:48:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
48 | if(vis[x][y]) continue; vis[x][y] = 1;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
7 |
Incorrect |
140 ms |
4252 KB |
Output isn't correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
27 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
28 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
29 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
30 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
31 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
32 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
33 |
Incorrect |
7 ms |
1052 KB |
Output isn't correct |
34 |
Incorrect |
8 ms |
860 KB |
Output isn't correct |
35 |
Incorrect |
33 ms |
1368 KB |
Output isn't correct |
36 |
Incorrect |
10 ms |
1112 KB |
Output isn't correct |
37 |
Incorrect |
10 ms |
1112 KB |
Output isn't correct |
38 |
Incorrect |
46 ms |
1312 KB |
Output isn't correct |
39 |
Incorrect |
12 ms |
1372 KB |
Output isn't correct |
40 |
Incorrect |
14 ms |
1372 KB |
Output isn't correct |
41 |
Incorrect |
57 ms |
1368 KB |
Output isn't correct |
42 |
Incorrect |
15 ms |
1628 KB |
Output isn't correct |
43 |
Incorrect |
18 ms |
1628 KB |
Output isn't correct |
44 |
Incorrect |
70 ms |
1768 KB |
Output isn't correct |
45 |
Incorrect |
17 ms |
1944 KB |
Output isn't correct |
46 |
Incorrect |
21 ms |
1880 KB |
Output isn't correct |
47 |
Incorrect |
85 ms |
2032 KB |
Output isn't correct |
48 |
Incorrect |
22 ms |
2140 KB |
Output isn't correct |
49 |
Incorrect |
21 ms |
2136 KB |
Output isn't correct |
50 |
Incorrect |
102 ms |
2340 KB |
Output isn't correct |
51 |
Incorrect |
23 ms |
2396 KB |
Output isn't correct |
52 |
Incorrect |
27 ms |
2396 KB |
Output isn't correct |
53 |
Incorrect |
132 ms |
2644 KB |
Output isn't correct |
54 |
Incorrect |
28 ms |
2904 KB |
Output isn't correct |
55 |
Incorrect |
29 ms |
2904 KB |
Output isn't correct |
56 |
Incorrect |
159 ms |
2904 KB |
Output isn't correct |
57 |
Incorrect |
31 ms |
3164 KB |
Output isn't correct |
58 |
Incorrect |
32 ms |
3232 KB |
Output isn't correct |
59 |
Incorrect |
175 ms |
3384 KB |
Output isn't correct |
60 |
Incorrect |
38 ms |
3668 KB |
Output isn't correct |
61 |
Incorrect |
42 ms |
3720 KB |
Output isn't correct |
62 |
Incorrect |
199 ms |
3764 KB |
Output isn't correct |
63 |
Incorrect |
148 ms |
3744 KB |
Output isn't correct |
64 |
Incorrect |
190 ms |
3752 KB |
Output isn't correct |
65 |
Incorrect |
207 ms |
3756 KB |
Output isn't correct |
66 |
Incorrect |
158 ms |
3668 KB |
Output isn't correct |
67 |
Correct |
167 ms |
3924 KB |
Output is correct |
68 |
Incorrect |
70 ms |
3784 KB |
Output isn't correct |
69 |
Incorrect |
65 ms |
3672 KB |
Output isn't correct |
70 |
Incorrect |
58 ms |
3676 KB |
Output isn't correct |
71 |
Incorrect |
56 ms |
3672 KB |
Output isn't correct |
72 |
Incorrect |
56 ms |
3788 KB |
Output isn't correct |
73 |
Incorrect |
105 ms |
5200 KB |
Output isn't correct |
74 |
Incorrect |
98 ms |
5200 KB |
Output isn't correct |
75 |
Incorrect |
106 ms |
5252 KB |
Output isn't correct |
76 |
Incorrect |
114 ms |
5392 KB |
Output isn't correct |
77 |
Incorrect |
112 ms |
5256 KB |
Output isn't correct |
78 |
Correct |
124 ms |
5088 KB |
Output is correct |
79 |
Incorrect |
100 ms |
5092 KB |
Output isn't correct |
80 |
Incorrect |
115 ms |
4952 KB |
Output isn't correct |
81 |
Incorrect |
122 ms |
4944 KB |
Output isn't correct |
82 |
Incorrect |
105 ms |
5084 KB |
Output isn't correct |
83 |
Incorrect |
128 ms |
4836 KB |
Output isn't correct |
84 |
Incorrect |
132 ms |
4668 KB |
Output isn't correct |
85 |
Incorrect |
113 ms |
4688 KB |
Output isn't correct |
86 |
Incorrect |
132 ms |
4688 KB |
Output isn't correct |
87 |
Incorrect |
132 ms |
4832 KB |
Output isn't correct |
88 |
Incorrect |
143 ms |
4572 KB |
Output isn't correct |
89 |
Incorrect |
139 ms |
4672 KB |
Output isn't correct |
90 |
Incorrect |
148 ms |
4440 KB |
Output isn't correct |
91 |
Incorrect |
146 ms |
4576 KB |
Output isn't correct |
92 |
Incorrect |
152 ms |
4440 KB |
Output isn't correct |