# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
53458 |
2018-06-30T05:13:08 Z |
장홍준(#2017) |
Mecho (IOI09_mecho) |
C++11 |
|
1000 ms |
3240 KB |
#include<stdio.h>
#include<deque>
using namespace std;
int n, S;
char M[818][818], NM[818][818], NNM[818][818];
int D[818][818];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
void spread() {
int i, j;
for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) if (NM[i][j] == 'H') {
for (int k = 0; k < 4; k++) {
if (NM[i + dx[k]][j + dy[k]] != 'T')NNM[i + dx[k]][j + dy[k]] = 'H';
}
}
for (i = 1; i <= n; i++)for (j = 1; j <= n; j++) {
if (NNM[i][j] == 'H')NM[i][j] = 'H';
NNM[i][j] = 0;
}
}
bool is_gone[818][818];
int f(int x) {
int i, j, sx, sy, ex, ey, nxt;
deque<int>qx, qy, qd;
for (i = 1; i <= n; i++)for (j = 1; j <= n; j++) {
if (M[i][j] == 'M')sx = i, sy = j;
if (M[i][j] == 'D')ex = i, ey = j;
NM[i][j] = M[i][j];
is_gone[i][j] = 0;
}
for (i = 0; i < x; i++)spread();
qx.push_back(sx); qy.push_back(sy); qd.push_back(0);
nxt = S;
while (!qx.empty()) {
int nowx = qx.front(); qx.pop_front();
int nowy = qy.front(); qy.pop_front();
int nowd = qd.front(); qd.pop_front();
if (nowd == nxt)
spread(), nxt += S;
if (NM[nowx][nowy] == 'H')continue;
if (nowx == ex && nowy == ey)return 1;
for (i = 0; i < 4; i++) {
int nx = nowx + dx[i], ny = nowy + dy[i];
if (nx <= 0 || ny <= 0 || nx > n || ny > n)continue;
if (is_gone[nx][ny])continue;
if (NM[nx][ny] == 'H')continue;
qx.push_back(nx); qy.push_back(ny); qd.push_back(nowd + 1);
is_gone[nx][ny] = 1;
}
}
return 0;
}
int main() { int i, j, s, e, ans = 0;
scanf("%d%d", &n, &S);
for (i = 1; i <= n; i++)for (j = 1; j <= n; j++)scanf(" %c", &M[i][j]);
s = 0, e = n * 2;
while (s <= e) {
int m = (s + e) / 2;
int k = f(m);
if (k)s = m + 1, ans = m;
else e = m - 1;
}
printf("%d", ans);
return 0;
}
Compilation message
mecho.cpp: In function 'int main()':
mecho.cpp:54:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &S);
~~~~~^~~~~~~~~~~~~~~~
mecho.cpp:55:55: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for (i = 1; i <= n; i++)for (j = 1; j <= n; j++)scanf(" %c", &M[i][j]);
~~~~~^~~~~~~~~~~~~~~~~
mecho.cpp: In function 'int f(int)':
mecho.cpp:41:26: warning: 'ey' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (nowx == ex && nowy == ey)return 1;
~~~~~^~~~~
mecho.cpp:41:12: warning: 'ex' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (nowx == ex && nowy == ey)return 1;
~~~~~^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Incorrect |
2 ms |
360 KB |
Output isn't correct |
3 |
Correct |
2 ms |
436 KB |
Output is correct |
4 |
Incorrect |
2 ms |
436 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
7 |
Execution timed out |
1081 ms |
2984 KB |
Time limit exceeded |
8 |
Incorrect |
2 ms |
2984 KB |
Output isn't correct |
9 |
Correct |
3 ms |
2984 KB |
Output is correct |
10 |
Correct |
2 ms |
2984 KB |
Output is correct |
11 |
Correct |
2 ms |
2984 KB |
Output is correct |
12 |
Incorrect |
7 ms |
2984 KB |
Output isn't correct |
13 |
Correct |
5 ms |
2984 KB |
Output is correct |
14 |
Incorrect |
13 ms |
2984 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
2984 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
2984 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
2984 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
2984 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
2984 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
2984 KB |
Output isn't correct |
21 |
Incorrect |
4 ms |
2984 KB |
Output isn't correct |
22 |
Incorrect |
4 ms |
2984 KB |
Output isn't correct |
23 |
Incorrect |
6 ms |
2984 KB |
Output isn't correct |
24 |
Incorrect |
6 ms |
2984 KB |
Output isn't correct |
25 |
Incorrect |
8 ms |
2984 KB |
Output isn't correct |
26 |
Incorrect |
10 ms |
2984 KB |
Output isn't correct |
27 |
Incorrect |
11 ms |
2984 KB |
Output isn't correct |
28 |
Incorrect |
13 ms |
2984 KB |
Output isn't correct |
29 |
Incorrect |
14 ms |
2984 KB |
Output isn't correct |
30 |
Incorrect |
15 ms |
2984 KB |
Output isn't correct |
31 |
Incorrect |
17 ms |
2984 KB |
Output isn't correct |
32 |
Incorrect |
18 ms |
2984 KB |
Output isn't correct |
33 |
Execution timed out |
1072 ms |
2984 KB |
Time limit exceeded |
34 |
Execution timed out |
1075 ms |
2984 KB |
Time limit exceeded |
35 |
Incorrect |
314 ms |
2984 KB |
Output isn't correct |
36 |
Execution timed out |
1055 ms |
2984 KB |
Time limit exceeded |
37 |
Execution timed out |
1078 ms |
2984 KB |
Time limit exceeded |
38 |
Incorrect |
418 ms |
2984 KB |
Output isn't correct |
39 |
Execution timed out |
1083 ms |
2984 KB |
Time limit exceeded |
40 |
Execution timed out |
1080 ms |
2984 KB |
Time limit exceeded |
41 |
Incorrect |
581 ms |
2984 KB |
Output isn't correct |
42 |
Execution timed out |
1049 ms |
2984 KB |
Time limit exceeded |
43 |
Execution timed out |
1067 ms |
2984 KB |
Time limit exceeded |
44 |
Incorrect |
827 ms |
2984 KB |
Output isn't correct |
45 |
Execution timed out |
1087 ms |
2984 KB |
Time limit exceeded |
46 |
Execution timed out |
1071 ms |
2984 KB |
Time limit exceeded |
47 |
Execution timed out |
1039 ms |
2984 KB |
Time limit exceeded |
48 |
Execution timed out |
1062 ms |
2984 KB |
Time limit exceeded |
49 |
Execution timed out |
1091 ms |
2984 KB |
Time limit exceeded |
50 |
Execution timed out |
1072 ms |
2984 KB |
Time limit exceeded |
51 |
Execution timed out |
1042 ms |
2984 KB |
Time limit exceeded |
52 |
Execution timed out |
1076 ms |
2984 KB |
Time limit exceeded |
53 |
Execution timed out |
1057 ms |
2984 KB |
Time limit exceeded |
54 |
Execution timed out |
1083 ms |
2984 KB |
Time limit exceeded |
55 |
Execution timed out |
1078 ms |
2984 KB |
Time limit exceeded |
56 |
Execution timed out |
1044 ms |
2984 KB |
Time limit exceeded |
57 |
Execution timed out |
1074 ms |
2984 KB |
Time limit exceeded |
58 |
Execution timed out |
1057 ms |
3028 KB |
Time limit exceeded |
59 |
Execution timed out |
1088 ms |
3028 KB |
Time limit exceeded |
60 |
Execution timed out |
1077 ms |
3072 KB |
Time limit exceeded |
61 |
Execution timed out |
1078 ms |
3184 KB |
Time limit exceeded |
62 |
Execution timed out |
1077 ms |
3184 KB |
Time limit exceeded |
63 |
Execution timed out |
1053 ms |
3184 KB |
Time limit exceeded |
64 |
Execution timed out |
1091 ms |
3184 KB |
Time limit exceeded |
65 |
Execution timed out |
1087 ms |
3184 KB |
Time limit exceeded |
66 |
Execution timed out |
1088 ms |
3184 KB |
Time limit exceeded |
67 |
Execution timed out |
1092 ms |
3204 KB |
Time limit exceeded |
68 |
Execution timed out |
1074 ms |
3240 KB |
Time limit exceeded |
69 |
Execution timed out |
1091 ms |
3240 KB |
Time limit exceeded |
70 |
Execution timed out |
1067 ms |
3240 KB |
Time limit exceeded |
71 |
Execution timed out |
1080 ms |
3240 KB |
Time limit exceeded |
72 |
Execution timed out |
1090 ms |
3240 KB |
Time limit exceeded |
73 |
Execution timed out |
1056 ms |
3240 KB |
Time limit exceeded |
74 |
Execution timed out |
1077 ms |
3240 KB |
Time limit exceeded |
75 |
Execution timed out |
1085 ms |
3240 KB |
Time limit exceeded |
76 |
Execution timed out |
1077 ms |
3240 KB |
Time limit exceeded |
77 |
Execution timed out |
1079 ms |
3240 KB |
Time limit exceeded |
78 |
Execution timed out |
1084 ms |
3240 KB |
Time limit exceeded |
79 |
Execution timed out |
1082 ms |
3240 KB |
Time limit exceeded |
80 |
Execution timed out |
1066 ms |
3240 KB |
Time limit exceeded |
81 |
Execution timed out |
1068 ms |
3240 KB |
Time limit exceeded |
82 |
Execution timed out |
1086 ms |
3240 KB |
Time limit exceeded |
83 |
Execution timed out |
1061 ms |
3240 KB |
Time limit exceeded |
84 |
Execution timed out |
1080 ms |
3240 KB |
Time limit exceeded |
85 |
Execution timed out |
1058 ms |
3240 KB |
Time limit exceeded |
86 |
Execution timed out |
1071 ms |
3240 KB |
Time limit exceeded |
87 |
Execution timed out |
1065 ms |
3240 KB |
Time limit exceeded |
88 |
Execution timed out |
1078 ms |
3240 KB |
Time limit exceeded |
89 |
Execution timed out |
1037 ms |
3240 KB |
Time limit exceeded |
90 |
Execution timed out |
1077 ms |
3240 KB |
Time limit exceeded |
91 |
Execution timed out |
1081 ms |
3240 KB |
Time limit exceeded |
92 |
Execution timed out |
1080 ms |
3240 KB |
Time limit exceeded |