# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
953284 |
2024-03-25T19:17:05 Z |
snowman |
Mecho (IOI09_mecho) |
C++17 |
|
549 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
//Soltan Cristian
#define ll long long
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define pb push_back
#define st first
#define nd second
#define sz(x) (ll)x.size()
#define rall(x) x.rbegin(), x.rend()
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int mxa = 2 * 1e5 + 2;
// string __fname = "maxflow";
// ifstream in(__fname + ".in");
// ofstream out (__fname + ".out");
// #define cin in
// #define cout out
int n, s;
vector<vector<char>> mapa;
bool validB(int x, int y){
if(x >= 0 && x < n && y >= 0 && y < n && mapa[x][y] != 'T' && mapa[x][y] != 'D'){
return true;
}
return false;
}
bool valid(int x, int y){
if(x >= 0 && x < n && y >= 0 && y < n && mapa[x][y] != 'T'){
return true;
}
return false;
}
void solve(){
cin >> n >> s;
mapa = vector<vector<char>>(n, vector<char>(n));
vector<pair<int,int>> stup;
pair<int, int> start, finish;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
char x;
cin >> x;
if(x == 'H') stup.pb({i, j});
if(x == 'M') start = {i, j};
if(x == 'D') finish = {i, j};
mapa[i][j] = x;
}
}
vector<vector<int>> bees(n, vector<int>(n, INT_MAX));
queue<pair<int, int>> qB;
for(int i = 0; i < sz(stup); i++){
bees[stup[i].st][stup[i].nd] = 0;
qB.push({stup[i].st, stup[i].nd});
}
// cout << "a\n";
while(!qB.empty()){
pair<int, int> u = qB.front();
qB.pop();
for(int i = 0; i < 4; i++){
if(!validB(u.st + dx[i], u.nd + dy[i])) continue;
if(bees[u.st][u.nd] + s <= bees[u.st + dx[i]][u.nd + dy[i]]){
qB.push({u.st + dx[i], u.nd + dy[i]});
bees[u.st + dx[i]][u.nd + dy[i]] = bees[u.st][u.nd] + s;
}
}
}
int l = 0, r = n * n;
int ans = 0;
while(l <= r){
int mid = (l + r) / 2;
vector<vector<int>> h(n, vector<int>(n, INT_MAX));
h[start.st][start.nd] = mid;
queue<pair<int,int>> q;
q.push({start.st, start.nd});
while(!q.empty()){
pair<int, int> u = q.front();
q.pop();
for(int i = 0; i < 4; i++){
if(!valid(u.st + dx[i], u.nd + dy[i])) continue;
if(h[u.st][u.nd] + 1 <= bees[u.st + dx[i]][u.nd + dy[i]] &&
h[u.st][u.nd] + 1 <= h[u.st + dx[i]][u.nd + dy[i]]){
q.push({u.st + dx[i], u.nd + dy[i]});
h[u.st + dx[i]][u.nd + dy[i]] = h[u.st][u.nd] + 1;
}
}
}
if(h[finish.st][finish.nd] < INT_MAX){
ans = max(ans, mid);
l = mid + 1;
}
else r = mid - 1;
}
// cout << ans << '\n';
cout << ans / s << '\n';
}
int main()
{
// ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << (setprecision(10));
// int t;
// cin >> t;
// while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Runtime error |
289 ms |
65536 KB |
Execution killed with signal 9 |
8 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
13 |
Runtime error |
342 ms |
65536 KB |
Execution killed with signal 9 |
14 |
Runtime error |
476 ms |
65536 KB |
Execution killed with signal 9 |
15 |
Incorrect |
0 ms |
356 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
444 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
356 KB |
Output isn't correct |
18 |
Incorrect |
1 ms |
360 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
356 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
344 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 |
344 KB |
Output isn't correct |
29 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
30 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
31 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
32 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
33 |
Incorrect |
9 ms |
1628 KB |
Output isn't correct |
34 |
Incorrect |
25 ms |
1652 KB |
Output isn't correct |
35 |
Runtime error |
250 ms |
65536 KB |
Execution killed with signal 9 |
36 |
Incorrect |
17 ms |
1888 KB |
Output isn't correct |
37 |
Incorrect |
48 ms |
1880 KB |
Output isn't correct |
38 |
Runtime error |
248 ms |
65536 KB |
Execution killed with signal 9 |
39 |
Incorrect |
15 ms |
2440 KB |
Output isn't correct |
40 |
Incorrect |
41 ms |
2436 KB |
Output isn't correct |
41 |
Runtime error |
248 ms |
65536 KB |
Execution killed with signal 9 |
42 |
Incorrect |
26 ms |
2844 KB |
Output isn't correct |
43 |
Incorrect |
70 ms |
2896 KB |
Output isn't correct |
44 |
Runtime error |
257 ms |
65536 KB |
Execution killed with signal 9 |
45 |
Incorrect |
32 ms |
3312 KB |
Output isn't correct |
46 |
Incorrect |
64 ms |
3348 KB |
Output isn't correct |
47 |
Runtime error |
284 ms |
65536 KB |
Execution killed with signal 9 |
48 |
Incorrect |
27 ms |
3952 KB |
Output isn't correct |
49 |
Incorrect |
76 ms |
3924 KB |
Output isn't correct |
50 |
Runtime error |
249 ms |
65536 KB |
Execution killed with signal 9 |
51 |
Incorrect |
30 ms |
4420 KB |
Output isn't correct |
52 |
Incorrect |
92 ms |
4780 KB |
Output isn't correct |
53 |
Runtime error |
255 ms |
65536 KB |
Execution killed with signal 9 |
54 |
Incorrect |
35 ms |
5132 KB |
Output isn't correct |
55 |
Incorrect |
105 ms |
5184 KB |
Output isn't correct |
56 |
Runtime error |
250 ms |
65536 KB |
Execution killed with signal 9 |
57 |
Incorrect |
40 ms |
5844 KB |
Output isn't correct |
58 |
Incorrect |
153 ms |
5824 KB |
Output isn't correct |
59 |
Runtime error |
252 ms |
65536 KB |
Execution killed with signal 9 |
60 |
Incorrect |
49 ms |
6692 KB |
Output isn't correct |
61 |
Incorrect |
164 ms |
6600 KB |
Output isn't correct |
62 |
Runtime error |
266 ms |
65536 KB |
Execution killed with signal 9 |
63 |
Correct |
141 ms |
6564 KB |
Output is correct |
64 |
Incorrect |
327 ms |
6748 KB |
Output isn't correct |
65 |
Correct |
188 ms |
6608 KB |
Output is correct |
66 |
Incorrect |
162 ms |
6620 KB |
Output isn't correct |
67 |
Incorrect |
129 ms |
6584 KB |
Output isn't correct |
68 |
Correct |
90 ms |
6620 KB |
Output is correct |
69 |
Correct |
83 ms |
6588 KB |
Output is correct |
70 |
Correct |
77 ms |
6624 KB |
Output is correct |
71 |
Correct |
67 ms |
6640 KB |
Output is correct |
72 |
Incorrect |
56 ms |
6640 KB |
Output isn't correct |
73 |
Runtime error |
519 ms |
65536 KB |
Execution killed with signal 9 |
74 |
Runtime error |
516 ms |
65536 KB |
Execution killed with signal 9 |
75 |
Runtime error |
549 ms |
65536 KB |
Execution killed with signal 9 |
76 |
Runtime error |
520 ms |
65536 KB |
Execution killed with signal 9 |
77 |
Runtime error |
514 ms |
65536 KB |
Execution killed with signal 9 |
78 |
Runtime error |
456 ms |
65536 KB |
Execution killed with signal 9 |
79 |
Runtime error |
460 ms |
65536 KB |
Execution killed with signal 9 |
80 |
Runtime error |
417 ms |
65536 KB |
Execution killed with signal 9 |
81 |
Runtime error |
415 ms |
65536 KB |
Execution killed with signal 9 |
82 |
Runtime error |
422 ms |
65536 KB |
Execution killed with signal 9 |
83 |
Runtime error |
349 ms |
65536 KB |
Execution killed with signal 9 |
84 |
Runtime error |
405 ms |
65536 KB |
Execution killed with signal 9 |
85 |
Runtime error |
353 ms |
65536 KB |
Execution killed with signal 9 |
86 |
Runtime error |
354 ms |
65536 KB |
Execution killed with signal 9 |
87 |
Runtime error |
366 ms |
65536 KB |
Execution killed with signal 9 |
88 |
Runtime error |
312 ms |
65536 KB |
Execution killed with signal 9 |
89 |
Runtime error |
337 ms |
65536 KB |
Execution killed with signal 9 |
90 |
Runtime error |
312 ms |
65536 KB |
Execution killed with signal 9 |
91 |
Runtime error |
327 ms |
65536 KB |
Execution killed with signal 9 |
92 |
Runtime error |
318 ms |
65536 KB |
Execution killed with signal 9 |