# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1038570 |
2024-07-30T02:11:31 Z |
Tepeyac |
Mecho (IOI09_mecho) |
C++11 |
|
1000 ms |
6228 KB |
#include <bits/stdc++.h>
using namespace std;
struct Cell
{
int x, y, p;
};
int n, s;
char ma[801][801];
int enj[801][801];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool isvalid(int i, int j)
{
return i >= 1 && i <= n && j >= 1 && j <= n;
}
bool monotone(int m)
{
queue<Cell> q;
char temp_ma[801][801];
memcpy(temp_ma, ma, sizeof(ma));
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
{
if(temp_ma[i][j] == 'M')
{
Cell nodo = {i, j, 0};
q.push(nodo);
}
}
}
while(!q.empty())
{
Cell Nodo = q.front();
q.pop();
for(int i = 0; i < 4; ++i)
{
for(int j = 1; j <= s; ++j)
{
int nx = Nodo.x + j * dx[i];
int ny = Nodo.y + j * dy[i];
if(!isvalid(nx, ny) || temp_ma[nx][ny] == 'H' || temp_ma[nx][ny] == 'T')
break;
if(m <= enj[nx][ny] && temp_ma[nx][ny] != 'M')
{
if(temp_ma[nx][ny] == 'D')
{
return true;
}
temp_ma[nx][ny] = 'M';
q.push({nx, ny, Nodo.p + 1});
}
}
}
}
return false;
}
int BSOTA(int a, int b)
{
while(a + 1 < b)
{
int m = (a + b) / 2;
if(monotone(m))
{
a = m;
} else
{
b = m;
}
}
return a;
}
int main()
{
cin.tie(0) -> sync_with_stdio(0);
cin >> n >> s;
pair<int, int> pos;
queue<pair<int, int>> q;
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
{
cin >> ma[i][j];
if(ma[i][j] == 'H')
{
q.push({i, j});
enj[i][j] = 0;
}
else
{
enj[i][j] = INT_MAX;
}
if(ma[i][j] == 'M')
{
pos = {i, j};
}
}
}
while(!q.empty())
{
int i2 = q.front().first, j2 = q.front().second;
q.pop();
for(int i = 0; i < 4; ++i)
{
int nx = dx[i] + i2;
int ny = dy[i] + j2;
if(isvalid(nx, ny) && ma[nx][ny] != 'D' && ma[nx][ny] != 'T' && ma[nx][ny] != 'H' && enj[nx][ny] == INT_MAX)
{
q.push({nx, ny});
enj[nx][ny] = enj[i2][j2] + 1;
}
}
}
int maxx = enj[pos.first][pos.second];
cout << BSOTA(0, maxx - 1) << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
7 |
Execution timed out |
1097 ms |
4224 KB |
Time limit exceeded |
8 |
Incorrect |
1 ms |
1112 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Incorrect |
1 ms |
3164 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
16 |
Correct |
1 ms |
1116 KB |
Output is correct |
17 |
Incorrect |
1 ms |
1112 KB |
Output isn't correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Incorrect |
1 ms |
1112 KB |
Output isn't correct |
20 |
Correct |
1 ms |
1116 KB |
Output is correct |
21 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
22 |
Correct |
1 ms |
1116 KB |
Output is correct |
23 |
Incorrect |
1 ms |
1292 KB |
Output isn't correct |
24 |
Correct |
1 ms |
1116 KB |
Output is correct |
25 |
Incorrect |
1 ms |
3320 KB |
Output isn't correct |
26 |
Correct |
1 ms |
3164 KB |
Output is correct |
27 |
Incorrect |
4 ms |
3164 KB |
Output isn't correct |
28 |
Correct |
1 ms |
1116 KB |
Output is correct |
29 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
30 |
Correct |
2 ms |
1372 KB |
Output is correct |
31 |
Incorrect |
1 ms |
1372 KB |
Output isn't correct |
32 |
Correct |
1 ms |
1368 KB |
Output is correct |
33 |
Incorrect |
4 ms |
2296 KB |
Output isn't correct |
34 |
Correct |
7 ms |
2480 KB |
Output is correct |
35 |
Incorrect |
825 ms |
3340 KB |
Output isn't correct |
36 |
Incorrect |
6 ms |
2648 KB |
Output isn't correct |
37 |
Correct |
9 ms |
2652 KB |
Output is correct |
38 |
Execution timed out |
1098 ms |
3524 KB |
Time limit exceeded |
39 |
Incorrect |
7 ms |
2648 KB |
Output isn't correct |
40 |
Correct |
11 ms |
2652 KB |
Output is correct |
41 |
Execution timed out |
1100 ms |
3920 KB |
Time limit exceeded |
42 |
Incorrect |
8 ms |
2908 KB |
Output isn't correct |
43 |
Correct |
15 ms |
3712 KB |
Output is correct |
44 |
Execution timed out |
1066 ms |
4908 KB |
Time limit exceeded |
45 |
Incorrect |
10 ms |
3164 KB |
Output isn't correct |
46 |
Correct |
15 ms |
3164 KB |
Output is correct |
47 |
Execution timed out |
1098 ms |
4812 KB |
Time limit exceeded |
48 |
Incorrect |
11 ms |
3672 KB |
Output isn't correct |
49 |
Correct |
18 ms |
3448 KB |
Output is correct |
50 |
Execution timed out |
1035 ms |
5256 KB |
Time limit exceeded |
51 |
Incorrect |
13 ms |
3420 KB |
Output isn't correct |
52 |
Correct |
21 ms |
3528 KB |
Output is correct |
53 |
Execution timed out |
1080 ms |
5628 KB |
Time limit exceeded |
54 |
Incorrect |
16 ms |
3676 KB |
Output isn't correct |
55 |
Correct |
31 ms |
3676 KB |
Output is correct |
56 |
Execution timed out |
1070 ms |
6052 KB |
Time limit exceeded |
57 |
Incorrect |
23 ms |
3932 KB |
Output isn't correct |
58 |
Correct |
29 ms |
3932 KB |
Output is correct |
59 |
Execution timed out |
1063 ms |
5972 KB |
Time limit exceeded |
60 |
Incorrect |
25 ms |
4104 KB |
Output isn't correct |
61 |
Correct |
33 ms |
4188 KB |
Output is correct |
62 |
Execution timed out |
1063 ms |
6228 KB |
Time limit exceeded |
63 |
Incorrect |
147 ms |
4184 KB |
Output isn't correct |
64 |
Incorrect |
177 ms |
4184 KB |
Output isn't correct |
65 |
Incorrect |
183 ms |
4188 KB |
Output isn't correct |
66 |
Incorrect |
132 ms |
4188 KB |
Output isn't correct |
67 |
Incorrect |
164 ms |
4204 KB |
Output isn't correct |
68 |
Incorrect |
41 ms |
4188 KB |
Output isn't correct |
69 |
Incorrect |
48 ms |
4136 KB |
Output isn't correct |
70 |
Incorrect |
41 ms |
4188 KB |
Output isn't correct |
71 |
Incorrect |
41 ms |
4188 KB |
Output isn't correct |
72 |
Incorrect |
28 ms |
4172 KB |
Output isn't correct |
73 |
Incorrect |
17 ms |
3676 KB |
Output isn't correct |
74 |
Execution timed out |
1051 ms |
4996 KB |
Time limit exceeded |
75 |
Incorrect |
207 ms |
4444 KB |
Output isn't correct |
76 |
Incorrect |
122 ms |
4444 KB |
Output isn't correct |
77 |
Incorrect |
417 ms |
4440 KB |
Output isn't correct |
78 |
Incorrect |
423 ms |
4440 KB |
Output isn't correct |
79 |
Execution timed out |
1034 ms |
5680 KB |
Time limit exceeded |
80 |
Incorrect |
274 ms |
4440 KB |
Output isn't correct |
81 |
Incorrect |
211 ms |
4444 KB |
Output isn't correct |
82 |
Incorrect |
428 ms |
4688 KB |
Output isn't correct |
83 |
Incorrect |
385 ms |
4188 KB |
Output isn't correct |
84 |
Execution timed out |
1065 ms |
5280 KB |
Time limit exceeded |
85 |
Incorrect |
439 ms |
4408 KB |
Output isn't correct |
86 |
Incorrect |
407 ms |
4412 KB |
Output isn't correct |
87 |
Execution timed out |
1062 ms |
4408 KB |
Time limit exceeded |
88 |
Incorrect |
815 ms |
4364 KB |
Output isn't correct |
89 |
Execution timed out |
1069 ms |
6012 KB |
Time limit exceeded |
90 |
Execution timed out |
1038 ms |
4360 KB |
Time limit exceeded |
91 |
Execution timed out |
1071 ms |
4444 KB |
Time limit exceeded |
92 |
Execution timed out |
1049 ms |
4356 KB |
Time limit exceeded |