# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
60043 |
2018-07-23T13:45:19 Z |
nvmdava |
Mecho (IOI09_mecho) |
C++17 |
|
1000 ms |
16892 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
using namespace std;
int n,s;
int t[802][802];
char c[802][802];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool pos(int x,int y, int now){
for(int i = 0; i < 4; i++){
if(c[x + dx[i]][y + dy[i]]=='D'){
return 1;
}
if(c[x + dx[i]][y + dy[i]]=='G'&&t[x + dx[i]][y + dy[i]] > now + 1){
c[x + dx[i]][y + dy[i]]='T';
if(pos(x + dx[i],y + dy[i],now+1)){
c[x + dx[i]][y + dy[i]]='G';
return 1;
};
c[x + dx[i]][y + dy[i]]='G';
}
}
return 0;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int i,j,xx,yy;
cin>>n>>s;
queue<pair<int, int > > q;
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
cin>>c[i][j];
if(c[i][j]=='H'){
q.push(mp(i,j));
} else if(c[i][j]=='M'){
xx=i;
yy=j;
}
}
}
int x,y;
while(!q.empty()){
x=q.front().ff;
y=q.front().ss;
q.pop();
for(i=0;i<4;i++){
if(c[x + dx[i]][y + dy[i]]=='G'&&t[x + dx[i]][y + dy[i]]==0){
t[x + dx[i]][y + dy[i]] = t[x][y]+s;
q.push(mp(x + dx[i] , y + dy[i]));
}
}
}
int l = 0 , r = 1e9,m;
if(pos(xx,yy,0)==0){
cout<<-1;
return 0;
}
while(l + 1 != r){
m = (l + r) / 2;
if(pos(xx,yy,m)){
l = m;
} else {
r = m;
}
}
cout<<l/s;
}
Compilation message
mecho.cpp: In function 'int main()':
mecho.cpp:66:9: warning: 'yy' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(pos(xx,yy,m)){
~~~^~~~~~~~~
mecho.cpp:66:9: warning: 'xx' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
432 KB |
Output is correct |
4 |
Correct |
4 ms |
508 KB |
Output is correct |
5 |
Correct |
3 ms |
636 KB |
Output is correct |
6 |
Correct |
3 ms |
636 KB |
Output is correct |
7 |
Execution timed out |
1078 ms |
4552 KB |
Time limit exceeded |
8 |
Correct |
3 ms |
4552 KB |
Output is correct |
9 |
Correct |
3 ms |
4552 KB |
Output is correct |
10 |
Correct |
3 ms |
4552 KB |
Output is correct |
11 |
Correct |
3 ms |
4552 KB |
Output is correct |
12 |
Incorrect |
3 ms |
4552 KB |
Output isn't correct |
13 |
Incorrect |
4 ms |
4552 KB |
Output isn't correct |
14 |
Execution timed out |
1080 ms |
4552 KB |
Time limit exceeded |
15 |
Correct |
3 ms |
4552 KB |
Output is correct |
16 |
Correct |
3 ms |
4552 KB |
Output is correct |
17 |
Correct |
3 ms |
4552 KB |
Output is correct |
18 |
Correct |
2 ms |
4552 KB |
Output is correct |
19 |
Correct |
3 ms |
4552 KB |
Output is correct |
20 |
Correct |
4 ms |
4552 KB |
Output is correct |
21 |
Correct |
3 ms |
4552 KB |
Output is correct |
22 |
Correct |
3 ms |
4552 KB |
Output is correct |
23 |
Correct |
4 ms |
4552 KB |
Output is correct |
24 |
Correct |
3 ms |
4552 KB |
Output is correct |
25 |
Correct |
3 ms |
4552 KB |
Output is correct |
26 |
Correct |
3 ms |
4552 KB |
Output is correct |
27 |
Correct |
3 ms |
4552 KB |
Output is correct |
28 |
Correct |
3 ms |
4552 KB |
Output is correct |
29 |
Correct |
3 ms |
4552 KB |
Output is correct |
30 |
Correct |
5 ms |
4552 KB |
Output is correct |
31 |
Correct |
5 ms |
4552 KB |
Output is correct |
32 |
Correct |
4 ms |
4552 KB |
Output is correct |
33 |
Correct |
13 ms |
4552 KB |
Output is correct |
34 |
Correct |
9 ms |
4552 KB |
Output is correct |
35 |
Execution timed out |
1089 ms |
4552 KB |
Time limit exceeded |
36 |
Correct |
11 ms |
4552 KB |
Output is correct |
37 |
Correct |
8 ms |
4552 KB |
Output is correct |
38 |
Execution timed out |
1081 ms |
5500 KB |
Time limit exceeded |
39 |
Correct |
13 ms |
5500 KB |
Output is correct |
40 |
Correct |
9 ms |
5500 KB |
Output is correct |
41 |
Execution timed out |
1080 ms |
6524 KB |
Time limit exceeded |
42 |
Correct |
16 ms |
6524 KB |
Output is correct |
43 |
Correct |
13 ms |
6524 KB |
Output is correct |
44 |
Execution timed out |
1072 ms |
7676 KB |
Time limit exceeded |
45 |
Correct |
18 ms |
7676 KB |
Output is correct |
46 |
Correct |
12 ms |
7676 KB |
Output is correct |
47 |
Execution timed out |
1090 ms |
8956 KB |
Time limit exceeded |
48 |
Correct |
23 ms |
8956 KB |
Output is correct |
49 |
Correct |
14 ms |
8956 KB |
Output is correct |
50 |
Execution timed out |
1083 ms |
10364 KB |
Time limit exceeded |
51 |
Correct |
25 ms |
10364 KB |
Output is correct |
52 |
Correct |
17 ms |
10364 KB |
Output is correct |
53 |
Execution timed out |
1070 ms |
11776 KB |
Time limit exceeded |
54 |
Correct |
30 ms |
11776 KB |
Output is correct |
55 |
Correct |
22 ms |
11776 KB |
Output is correct |
56 |
Execution timed out |
1071 ms |
13436 KB |
Time limit exceeded |
57 |
Correct |
35 ms |
13436 KB |
Output is correct |
58 |
Correct |
21 ms |
13436 KB |
Output is correct |
59 |
Execution timed out |
1087 ms |
15052 KB |
Time limit exceeded |
60 |
Correct |
36 ms |
15052 KB |
Output is correct |
61 |
Correct |
24 ms |
15052 KB |
Output is correct |
62 |
Execution timed out |
1075 ms |
16892 KB |
Time limit exceeded |
63 |
Correct |
139 ms |
16892 KB |
Output is correct |
64 |
Correct |
243 ms |
16892 KB |
Output is correct |
65 |
Correct |
206 ms |
16892 KB |
Output is correct |
66 |
Correct |
143 ms |
16892 KB |
Output is correct |
67 |
Correct |
53 ms |
16892 KB |
Output is correct |
68 |
Correct |
78 ms |
16892 KB |
Output is correct |
69 |
Correct |
63 ms |
16892 KB |
Output is correct |
70 |
Correct |
48 ms |
16892 KB |
Output is correct |
71 |
Correct |
58 ms |
16892 KB |
Output is correct |
72 |
Incorrect |
51 ms |
16892 KB |
Output isn't correct |
73 |
Execution timed out |
1076 ms |
16892 KB |
Time limit exceeded |
74 |
Execution timed out |
1069 ms |
16892 KB |
Time limit exceeded |
75 |
Execution timed out |
1080 ms |
16892 KB |
Time limit exceeded |
76 |
Execution timed out |
1072 ms |
16892 KB |
Time limit exceeded |
77 |
Execution timed out |
1063 ms |
16892 KB |
Time limit exceeded |
78 |
Execution timed out |
1069 ms |
16892 KB |
Time limit exceeded |
79 |
Execution timed out |
1091 ms |
16892 KB |
Time limit exceeded |
80 |
Execution timed out |
1076 ms |
16892 KB |
Time limit exceeded |
81 |
Execution timed out |
1078 ms |
16892 KB |
Time limit exceeded |
82 |
Execution timed out |
1087 ms |
16892 KB |
Time limit exceeded |
83 |
Execution timed out |
1079 ms |
16892 KB |
Time limit exceeded |
84 |
Execution timed out |
1073 ms |
16892 KB |
Time limit exceeded |
85 |
Execution timed out |
1061 ms |
16892 KB |
Time limit exceeded |
86 |
Execution timed out |
1079 ms |
16892 KB |
Time limit exceeded |
87 |
Execution timed out |
1080 ms |
16892 KB |
Time limit exceeded |
88 |
Execution timed out |
1078 ms |
16892 KB |
Time limit exceeded |
89 |
Execution timed out |
1069 ms |
16892 KB |
Time limit exceeded |
90 |
Execution timed out |
1068 ms |
16892 KB |
Time limit exceeded |
91 |
Execution timed out |
1077 ms |
16892 KB |
Time limit exceeded |
92 |
Execution timed out |
1071 ms |
16892 KB |
Time limit exceeded |