# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
956820 |
2024-04-02T14:07:28 Z |
wood |
Mecho (IOI09_mecho) |
C++17 |
|
120 ms |
6480 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
int dfx[4] = {1,-1,0,0}; int dfy[4] = {0,0,1,-1};
int main()
{
fast_cin();
#ifndef ONLINE_JUDGE
#ifdef _WIN32
freopen("input.in", "r", stdin);
freopen("input.out", "w", stdout);
#endif
#endif
int n,s; cin>>n>>s;
char arr[n][n];
int bees[n][n];
fill(bees[0],bees[0]+n*n,INT_MAX);
queue<p32> hq;
p32 start;
for (size_t i = 0; i < n; i++)
{
for (size_t j = 0; j < n; j++)
{
cin>>arr[i][j];
if(arr[i][j]=='H'){
bees[i][j] = 1;
hq.emplace(i,j);
}
if(arr[i][j]=='D') start = p32(i,j);
}
}
while(!hq.empty()){
for (size_t i = 0; i < 4; i++)
{
int x = hq.front().fi+dfx[i];
int y = hq.front().se+dfy[i];
if(x>=0&&x<n&&y>=0&&y<n&&bees[x][y]==INT_MAX&&arr[x][y]!='T'&&arr[x][y]!='M'){
bees[x][y] = bees[hq.front().fi][hq.front().se] + 1;
hq.emplace(x,y);
}
}
hq.pop();
}
int l = -1;
int r = 1000;
while(r-l>1){
int mid = (l+r)/2;
queue<p32> q;
q.push(start);
int depth[n][n];
memset(depth,0,sizeof depth);
depth[start.fi][start.se] = 1;
while(!q.empty()){
for (size_t i = 0; i < 4; i++)
{
int x = q.front().fi+dfx[i];
int y = q.front().se+dfy[i];
int d = depth[q.front().fi][q.front().se];
if(x>=0&&x<n&&y>=0&&y<n&&!depth[x][y]&&arr[x][y]!='T'&&(d+1)/s+mid<bees[x][y]){
if(arr[x][y]=='M'&&mid<bees[start.fi][start.se]){
l = mid;
goto next;
}
depth[x][y] = d+1;
q.emplace(x,y);
}
}
q.pop();
}
r = mid;
next:
continue;
}
cout<<l<<'\n';
return 0;
}
Compilation message
mecho.cpp: In function 'int main()':
mecho.cpp:31:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
31 | for (size_t i = 0; i < n; i++)
| ~~^~~
mecho.cpp:33:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
33 | for (size_t j = 0; j < n; j++)
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
53 ms |
6180 KB |
Output isn't correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
23 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
24 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
25 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
27 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
28 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
29 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
30 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
33 |
Incorrect |
3 ms |
1356 KB |
Output isn't correct |
34 |
Incorrect |
3 ms |
1368 KB |
Output isn't correct |
35 |
Incorrect |
6 ms |
1372 KB |
Output isn't correct |
36 |
Incorrect |
4 ms |
1628 KB |
Output isn't correct |
37 |
Incorrect |
4 ms |
1624 KB |
Output isn't correct |
38 |
Incorrect |
8 ms |
1628 KB |
Output isn't correct |
39 |
Incorrect |
4 ms |
2136 KB |
Output isn't correct |
40 |
Incorrect |
5 ms |
2140 KB |
Output isn't correct |
41 |
Incorrect |
10 ms |
2140 KB |
Output isn't correct |
42 |
Incorrect |
6 ms |
2652 KB |
Output isn't correct |
43 |
Incorrect |
6 ms |
2448 KB |
Output isn't correct |
44 |
Incorrect |
12 ms |
2652 KB |
Output isn't correct |
45 |
Incorrect |
7 ms |
2960 KB |
Output isn't correct |
46 |
Incorrect |
7 ms |
2956 KB |
Output isn't correct |
47 |
Incorrect |
15 ms |
2908 KB |
Output isn't correct |
48 |
Incorrect |
8 ms |
3496 KB |
Output isn't correct |
49 |
Incorrect |
8 ms |
3380 KB |
Output isn't correct |
50 |
Incorrect |
18 ms |
3488 KB |
Output isn't correct |
51 |
Incorrect |
10 ms |
3932 KB |
Output isn't correct |
52 |
Incorrect |
10 ms |
3928 KB |
Output isn't correct |
53 |
Incorrect |
20 ms |
3928 KB |
Output isn't correct |
54 |
Incorrect |
11 ms |
4640 KB |
Output isn't correct |
55 |
Incorrect |
11 ms |
4700 KB |
Output isn't correct |
56 |
Incorrect |
25 ms |
4636 KB |
Output isn't correct |
57 |
Incorrect |
15 ms |
5212 KB |
Output isn't correct |
58 |
Incorrect |
13 ms |
5212 KB |
Output isn't correct |
59 |
Incorrect |
28 ms |
5412 KB |
Output isn't correct |
60 |
Incorrect |
14 ms |
5980 KB |
Output isn't correct |
61 |
Incorrect |
14 ms |
5976 KB |
Output isn't correct |
62 |
Incorrect |
36 ms |
5888 KB |
Output isn't correct |
63 |
Incorrect |
91 ms |
6224 KB |
Output isn't correct |
64 |
Incorrect |
112 ms |
5872 KB |
Output isn't correct |
65 |
Incorrect |
120 ms |
6068 KB |
Output isn't correct |
66 |
Incorrect |
107 ms |
5972 KB |
Output isn't correct |
67 |
Incorrect |
88 ms |
5864 KB |
Output isn't correct |
68 |
Incorrect |
42 ms |
5872 KB |
Output isn't correct |
69 |
Incorrect |
50 ms |
5980 KB |
Output isn't correct |
70 |
Incorrect |
41 ms |
5912 KB |
Output isn't correct |
71 |
Incorrect |
38 ms |
5904 KB |
Output isn't correct |
72 |
Incorrect |
28 ms |
6236 KB |
Output isn't correct |
73 |
Incorrect |
36 ms |
6232 KB |
Output isn't correct |
74 |
Incorrect |
35 ms |
6348 KB |
Output isn't correct |
75 |
Incorrect |
38 ms |
6164 KB |
Output isn't correct |
76 |
Incorrect |
33 ms |
6232 KB |
Output isn't correct |
77 |
Incorrect |
35 ms |
6236 KB |
Output isn't correct |
78 |
Incorrect |
35 ms |
6116 KB |
Output isn't correct |
79 |
Incorrect |
33 ms |
6480 KB |
Output isn't correct |
80 |
Incorrect |
42 ms |
6228 KB |
Output isn't correct |
81 |
Incorrect |
36 ms |
6232 KB |
Output isn't correct |
82 |
Incorrect |
34 ms |
6236 KB |
Output isn't correct |
83 |
Incorrect |
33 ms |
6276 KB |
Output isn't correct |
84 |
Incorrect |
33 ms |
6096 KB |
Output isn't correct |
85 |
Incorrect |
51 ms |
6284 KB |
Output isn't correct |
86 |
Incorrect |
33 ms |
6236 KB |
Output isn't correct |
87 |
Incorrect |
37 ms |
6276 KB |
Output isn't correct |
88 |
Incorrect |
39 ms |
6236 KB |
Output isn't correct |
89 |
Incorrect |
36 ms |
6232 KB |
Output isn't correct |
90 |
Incorrect |
36 ms |
6236 KB |
Output isn't correct |
91 |
Incorrect |
37 ms |
6072 KB |
Output isn't correct |
92 |
Incorrect |
35 ms |
6052 KB |
Output isn't correct |