# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
763893 |
2023-06-23T02:34:21 Z |
hanlulu |
Mecho (IOI09_mecho) |
C++14 |
|
186 ms |
6748 KB |
//https://cses.fi/problemset/task/1707
#include <bits/stdc++.h>
using namespace std;
/*
有点像793的题目,两次最短。Bee走出到每一个位置的最短,
然后二分答案,然后Mecho走最短的时侯每一个相邻是否可以走需要计算是否Bee先到。
如何处理一分钟走s步这里?dis记录当前的步数,每次走到相邻+1,但是时间可以用dis/s得到。
*/
int n,s;
char a[801][801];
int rdir[4] = {0,0,1,-1};
int cdir[4] = {1,-1,0,0};
vector<vector<int>> beetime(801,vector<int>(801,1e9));
int sx,sy,ex,ey;//起点和终点
bool isok(int eat)//eat is how many time he stay at start point.
{
vector<vector<int>> mstep(801,vector<int>(801,1e9));
//cout << eat << endl;
queue<pair<int,int>> myq;
mstep[sx][sy] = 0;
myq.push({sx,sy});
while (!myq.empty()) {
int x = myq.front().first;
int y = myq.front().second;
myq.pop();
for (int i = 0; i < 4; i++)
{
int newx = x + rdir[i];
int newy = y + cdir[i];
if (newx <0 || newx == n || newy < 0 || newy == n) continue;
if (a[newx][newy] == 'T' || a[newx][newy] == 'H') continue;
if (mstep[newx][newy] <= mstep[x][y] + 1) continue;
if (beetime[newx][newy] < ceil(1.0*(mstep[x][y]+1) /s) + eat) continue;
//cout << newx << " " << newy << " " << (mstep[x][y]+1) /s + eat << endl;
mstep[newx][newy] = mstep[x][y] + 1;
//if (a[newx][newy] == 'D') break;
myq.push({newx,newy});
}
}
//cout << mstep[2][2] << endl;
return mstep[ex][ey] != 1e9;
}
int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);
//cout.tie(0);
//freopen("nocross.in","r",stdin);
//freopen("nocross.out","w",stdout);
cin >> n >> s;
queue<pair<int,int>> myq;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
cin >> a[i][j];
if (a[i][j] == 'M') sx = i, sy = j;
if (a[i][j] == 'D') ex = i, ey = j;
if (a[i][j] == 'H') {
beetime[i][j] = 0;
myq.push({i,j});
};
}
//find beetime
while (!myq.empty()) {
int x = myq.front().first;
int y = myq.front().second;
myq.pop();
for (int i = 0; i < 4; i++)
{
int newx = x + rdir[i];
int newy = y + cdir[i];
if (newx <0 || newx == n || newy < 0 || newy == n) continue;
if (a[newx][newy] == 'T' || a[newx][newy] == 'H') continue;
if (beetime[newx][newy] <= beetime[x][y] + 1) continue;
beetime[newx][newy] = beetime[x][y] + 1;
if (a[newx][newy] != 'D' )//can not go throuh home, but need know the time bee arrive
myq.push({newx,newy});
}
}
// cout << beetime[2][2]<< endl;
//bin the answer
int ans = -1;
int l = 0, r = n*n, mid;
while (l <= r) {
mid = (l+r)/2;
//cout << "mid " << mid << endl;
if (isok(mid)) {
ans = mid;
l = mid + 1;
}
else r = mid - 1;
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
5392 KB |
Output isn't correct |
2 |
Incorrect |
5 ms |
5412 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
5372 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
5404 KB |
Output isn't correct |
5 |
Correct |
6 ms |
5372 KB |
Output is correct |
6 |
Incorrect |
7 ms |
5412 KB |
Output isn't correct |
7 |
Incorrect |
115 ms |
6664 KB |
Output isn't correct |
8 |
Incorrect |
7 ms |
5412 KB |
Output isn't correct |
9 |
Correct |
7 ms |
5412 KB |
Output is correct |
10 |
Correct |
6 ms |
5412 KB |
Output is correct |
11 |
Correct |
6 ms |
5412 KB |
Output is correct |
12 |
Incorrect |
9 ms |
5460 KB |
Output isn't correct |
13 |
Incorrect |
9 ms |
5476 KB |
Output isn't correct |
14 |
Correct |
8 ms |
5456 KB |
Output is correct |
15 |
Incorrect |
7 ms |
5444 KB |
Output isn't correct |
16 |
Correct |
9 ms |
5428 KB |
Output is correct |
17 |
Incorrect |
7 ms |
5432 KB |
Output isn't correct |
18 |
Correct |
8 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
8 ms |
5472 KB |
Output isn't correct |
20 |
Correct |
7 ms |
5472 KB |
Output is correct |
21 |
Incorrect |
9 ms |
5440 KB |
Output isn't correct |
22 |
Correct |
8 ms |
5436 KB |
Output is correct |
23 |
Incorrect |
8 ms |
5452 KB |
Output isn't correct |
24 |
Correct |
9 ms |
5460 KB |
Output is correct |
25 |
Incorrect |
9 ms |
5452 KB |
Output isn't correct |
26 |
Correct |
9 ms |
5472 KB |
Output is correct |
27 |
Incorrect |
9 ms |
5464 KB |
Output isn't correct |
28 |
Correct |
10 ms |
5472 KB |
Output is correct |
29 |
Incorrect |
9 ms |
5472 KB |
Output isn't correct |
30 |
Correct |
10 ms |
5488 KB |
Output is correct |
31 |
Incorrect |
10 ms |
5524 KB |
Output isn't correct |
32 |
Correct |
10 ms |
5488 KB |
Output is correct |
33 |
Incorrect |
18 ms |
5828 KB |
Output isn't correct |
34 |
Correct |
19 ms |
5816 KB |
Output is correct |
35 |
Correct |
35 ms |
5804 KB |
Output is correct |
36 |
Incorrect |
21 ms |
5916 KB |
Output isn't correct |
37 |
Correct |
21 ms |
5900 KB |
Output is correct |
38 |
Correct |
42 ms |
5884 KB |
Output is correct |
39 |
Incorrect |
22 ms |
6048 KB |
Output isn't correct |
40 |
Correct |
24 ms |
6004 KB |
Output is correct |
41 |
Correct |
57 ms |
6004 KB |
Output is correct |
42 |
Incorrect |
25 ms |
6060 KB |
Output isn't correct |
43 |
Correct |
27 ms |
6124 KB |
Output is correct |
44 |
Correct |
65 ms |
6052 KB |
Output is correct |
45 |
Incorrect |
29 ms |
6148 KB |
Output isn't correct |
46 |
Correct |
28 ms |
6140 KB |
Output is correct |
47 |
Correct |
72 ms |
6124 KB |
Output is correct |
48 |
Incorrect |
32 ms |
6256 KB |
Output isn't correct |
49 |
Correct |
33 ms |
6248 KB |
Output is correct |
50 |
Correct |
83 ms |
6236 KB |
Output is correct |
51 |
Incorrect |
36 ms |
6424 KB |
Output isn't correct |
52 |
Correct |
35 ms |
6352 KB |
Output is correct |
53 |
Correct |
103 ms |
6348 KB |
Output is correct |
54 |
Incorrect |
38 ms |
6444 KB |
Output isn't correct |
55 |
Correct |
39 ms |
6452 KB |
Output is correct |
56 |
Correct |
118 ms |
6440 KB |
Output is correct |
57 |
Incorrect |
42 ms |
6580 KB |
Output isn't correct |
58 |
Correct |
46 ms |
6684 KB |
Output is correct |
59 |
Correct |
136 ms |
6592 KB |
Output is correct |
60 |
Incorrect |
46 ms |
6660 KB |
Output isn't correct |
61 |
Correct |
48 ms |
6676 KB |
Output is correct |
62 |
Correct |
153 ms |
6644 KB |
Output is correct |
63 |
Correct |
111 ms |
6716 KB |
Output is correct |
64 |
Correct |
186 ms |
6664 KB |
Output is correct |
65 |
Correct |
146 ms |
6656 KB |
Output is correct |
66 |
Incorrect |
137 ms |
6652 KB |
Output isn't correct |
67 |
Correct |
120 ms |
6656 KB |
Output is correct |
68 |
Correct |
76 ms |
6748 KB |
Output is correct |
69 |
Correct |
67 ms |
6748 KB |
Output is correct |
70 |
Correct |
57 ms |
6684 KB |
Output is correct |
71 |
Correct |
63 ms |
6704 KB |
Output is correct |
72 |
Incorrect |
53 ms |
6684 KB |
Output isn't correct |
73 |
Incorrect |
64 ms |
6708 KB |
Output isn't correct |
74 |
Correct |
83 ms |
6684 KB |
Output is correct |
75 |
Correct |
98 ms |
6680 KB |
Output is correct |
76 |
Correct |
87 ms |
6680 KB |
Output is correct |
77 |
Correct |
87 ms |
6672 KB |
Output is correct |
78 |
Correct |
102 ms |
6676 KB |
Output is correct |
79 |
Correct |
73 ms |
6700 KB |
Output is correct |
80 |
Correct |
84 ms |
6676 KB |
Output is correct |
81 |
Correct |
94 ms |
6688 KB |
Output is correct |
82 |
Correct |
84 ms |
6692 KB |
Output is correct |
83 |
Correct |
103 ms |
6688 KB |
Output is correct |
84 |
Correct |
94 ms |
6676 KB |
Output is correct |
85 |
Correct |
111 ms |
6664 KB |
Output is correct |
86 |
Correct |
99 ms |
6740 KB |
Output is correct |
87 |
Correct |
100 ms |
6668 KB |
Output is correct |
88 |
Correct |
105 ms |
6696 KB |
Output is correct |
89 |
Correct |
106 ms |
6660 KB |
Output is correct |
90 |
Correct |
109 ms |
6676 KB |
Output is correct |
91 |
Correct |
109 ms |
6696 KB |
Output is correct |
92 |
Correct |
116 ms |
6688 KB |
Output is correct |