# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101367 |
2024-10-16T07:24:23 Z |
jadai007 |
Mecho (IOI09_mecho) |
C++17 |
|
331 ms |
20040 KB |
#include<bits/stdc++.h>
using namespace std;
int n, s, disH[1010][1010], dis[1010][1010], xx[] = {0, 0, -1, 1}, xy[] = {-1, 1, 0, 0};
char mp[1010][1010];
queue<tuple<int, int, int>> q;
bool solve(int mid){
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
if(mp[i][j] == 'M') q.emplace(i, j, mid*s), dis[i][j] = mid*s;
else dis[i][j] = 1e9;
}
}
while(!q.empty()){
int x = get<0>(q.front()), y = get<1>(q.front()), w = get<2>(q.front()); q.pop();
if(dis[x][y] < w || dis[x][y] >= disH[x][y]) continue;
if(mp[x][y] == 'D') return true;
for(int i = 0; i < 4; ++i){
int nx = x + xx[i];
int ny = y + xy[i];
if(nx < 1 || nx > n || ny < 1 || ny > n || mp[nx][ny] == 'T') continue;
if(dis[nx][ny] > w + 1){
dis[nx][ny] = w + 1;
q.emplace(nx, ny, w + 1);
}
}
}
return false;
}
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> s;
for(int i = 1; i<=n; ++i) for(int j = 1; j <= n; ++j) cin >> mp[i][j];
for(int i = 1; i <= n; ++i){
for(int j = 1; j <=n; ++j){
if(mp[i][j] == 'H') q.emplace(i, j, 0), disH[i][j] = 0;
else disH[i][j] = 1e9;
}
}
while(!q.empty()){
int x = get<0>(q.front()), y = get<1>(q.front()), w = get<2>(q.front()); q.pop();
if(disH[x][y] < w) continue;
for(int i = 0; i < 4; ++i){
int nx = x + xx[i];
int ny = y + xy[i];
if(nx < 1 || nx > n || ny < 1 || ny > n || mp[nx][ny] == 'T') continue;
if(disH[nx][ny] > w + 1){
disH[nx][ny] = w + 1;
q.emplace(nx, ny, w + 1);
}
}
}
for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) disH[i][j] == 1e9 ? disH[i][j] *= 1 : disH[i][j] *= s;
int l = 0, r = 1e9, ans = -1;
for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) cout << i << ' ' << j << ' ' << disH[i][j] << '\n';
while(l <= r){
int mid = (l + r) >> 1;
if(solve(mid)) ans = mid, l = mid + 1;
else r = mid - 1;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
4600 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
7 |
Incorrect |
249 ms |
16940 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
4432 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
4432 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
4432 KB |
Output isn't correct |
26 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
27 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
28 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
29 |
Incorrect |
2 ms |
4632 KB |
Output isn't correct |
30 |
Incorrect |
3 ms |
4688 KB |
Output isn't correct |
31 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
4688 KB |
Output isn't correct |
33 |
Incorrect |
25 ms |
10576 KB |
Output isn't correct |
34 |
Incorrect |
25 ms |
10832 KB |
Output isn't correct |
35 |
Incorrect |
53 ms |
10576 KB |
Output isn't correct |
36 |
Incorrect |
33 ms |
11344 KB |
Output isn't correct |
37 |
Incorrect |
36 ms |
11344 KB |
Output isn't correct |
38 |
Incorrect |
65 ms |
11240 KB |
Output isn't correct |
39 |
Incorrect |
47 ms |
11900 KB |
Output isn't correct |
40 |
Incorrect |
43 ms |
12140 KB |
Output isn't correct |
41 |
Incorrect |
77 ms |
11748 KB |
Output isn't correct |
42 |
Incorrect |
57 ms |
12892 KB |
Output isn't correct |
43 |
Incorrect |
60 ms |
13072 KB |
Output isn't correct |
44 |
Incorrect |
102 ms |
12660 KB |
Output isn't correct |
45 |
Incorrect |
61 ms |
13628 KB |
Output isn't correct |
46 |
Incorrect |
71 ms |
13888 KB |
Output isn't correct |
47 |
Incorrect |
116 ms |
13536 KB |
Output isn't correct |
48 |
Incorrect |
76 ms |
14700 KB |
Output isn't correct |
49 |
Incorrect |
78 ms |
15084 KB |
Output isn't correct |
50 |
Incorrect |
145 ms |
14420 KB |
Output isn't correct |
51 |
Incorrect |
98 ms |
15608 KB |
Output isn't correct |
52 |
Incorrect |
94 ms |
16208 KB |
Output isn't correct |
53 |
Incorrect |
173 ms |
15456 KB |
Output isn't correct |
54 |
Incorrect |
96 ms |
16772 KB |
Output isn't correct |
55 |
Incorrect |
94 ms |
17400 KB |
Output isn't correct |
56 |
Incorrect |
163 ms |
16456 KB |
Output isn't correct |
57 |
Incorrect |
108 ms |
17996 KB |
Output isn't correct |
58 |
Incorrect |
106 ms |
18760 KB |
Output isn't correct |
59 |
Incorrect |
181 ms |
17748 KB |
Output isn't correct |
60 |
Incorrect |
133 ms |
19272 KB |
Output isn't correct |
61 |
Incorrect |
128 ms |
20040 KB |
Output isn't correct |
62 |
Incorrect |
210 ms |
18760 KB |
Output isn't correct |
63 |
Incorrect |
181 ms |
18492 KB |
Output isn't correct |
64 |
Incorrect |
331 ms |
19536 KB |
Output isn't correct |
65 |
Incorrect |
229 ms |
18504 KB |
Output isn't correct |
66 |
Incorrect |
230 ms |
18512 KB |
Output isn't correct |
67 |
Incorrect |
185 ms |
18460 KB |
Output isn't correct |
68 |
Incorrect |
287 ms |
18500 KB |
Output isn't correct |
69 |
Incorrect |
269 ms |
18760 KB |
Output isn't correct |
70 |
Incorrect |
316 ms |
18248 KB |
Output isn't correct |
71 |
Incorrect |
291 ms |
18412 KB |
Output isn't correct |
72 |
Incorrect |
141 ms |
18764 KB |
Output isn't correct |
73 |
Incorrect |
238 ms |
16712 KB |
Output isn't correct |
74 |
Incorrect |
200 ms |
17736 KB |
Output isn't correct |
75 |
Incorrect |
216 ms |
16712 KB |
Output isn't correct |
76 |
Incorrect |
209 ms |
16660 KB |
Output isn't correct |
77 |
Incorrect |
218 ms |
16968 KB |
Output isn't correct |
78 |
Incorrect |
237 ms |
16712 KB |
Output isn't correct |
79 |
Incorrect |
263 ms |
17736 KB |
Output isn't correct |
80 |
Incorrect |
223 ms |
16892 KB |
Output isn't correct |
81 |
Incorrect |
203 ms |
16644 KB |
Output isn't correct |
82 |
Incorrect |
218 ms |
16976 KB |
Output isn't correct |
83 |
Incorrect |
245 ms |
16856 KB |
Output isn't correct |
84 |
Incorrect |
225 ms |
17736 KB |
Output isn't correct |
85 |
Incorrect |
193 ms |
16968 KB |
Output isn't correct |
86 |
Incorrect |
234 ms |
16712 KB |
Output isn't correct |
87 |
Incorrect |
216 ms |
16976 KB |
Output isn't correct |
88 |
Incorrect |
235 ms |
16712 KB |
Output isn't correct |
89 |
Incorrect |
243 ms |
17736 KB |
Output isn't correct |
90 |
Incorrect |
264 ms |
16968 KB |
Output isn't correct |
91 |
Incorrect |
248 ms |
17228 KB |
Output isn't correct |
92 |
Incorrect |
243 ms |
17020 KB |
Output isn't correct |