# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1093729 |
2024-09-27T10:41:35 Z |
Abito |
Maze (JOI23_ho_t3) |
C++17 |
|
2000 ms |
10076 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
//#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=400,M=2e5;
int dis[N][M],n,m,k,p[N][M],sx,sy,ex,ey,mvx[]={1,0,-1,0},mvy[]={0,1,0,-1};
char a[N][M];
bool vis[N][M];
bool ok(int x,int y){
return x>=1 && x<=n && y>=1 && y<=m && a[x][y]=='.';
}
void bfs1(){
deque<pair<int,int>> dq;
dq.push_front({sx,sy});
dis[sx][sy]=0;
while (!dq.empty()){
int x=dq.front().F,y=dq.front().S;
dq.pop_front();
if (vis[x][y]) continue;
//cout<<x<<' '<<y<<' '<<dis[x][y]<<endl;
vis[x][y]=1;
for (int i=0;i<4;i++){
int nx=mvx[i]+x,ny=mvy[i]+y;
if (!ok(nx,ny)) continue;
if (dis[nx][ny]>dis[x][y]){
dis[nx][ny]=dis[x][y];
dq.push_front({nx,ny});
}
}
for (int i=max(1,x-k);i<=min(n,x+k);i++){
for (int j=max(1,y-k);j<=min(m,y+k);j++){
if (i==x-k && j==y-k) continue;
if (i==x-k && j==y+k) continue;
if (i==x+k && j==y-k) continue;
if (i==x+k && j==y+k) continue;
if (dis[i][j]>dis[x][y]+1){
dis[i][j]=dis[x][y]+1;
dq.push_back({i,j});
}
}
}
//return;
}
return;
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m>>k>>sx>>sy>>ex>>ey;
for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) cin>>a[i][j],dis[i][j]=INT_MAX;
if ((2*k+1)*(2*k+1)<=INT_MAX) bfs1();
else ;
cout<<dis[ex][ey]<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
860 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
860 KB |
Output is correct |
18 |
Correct |
0 ms |
860 KB |
Output is correct |
19 |
Correct |
4 ms |
4188 KB |
Output is correct |
20 |
Correct |
1 ms |
628 KB |
Output is correct |
21 |
Correct |
4 ms |
4696 KB |
Output is correct |
22 |
Correct |
6 ms |
4188 KB |
Output is correct |
23 |
Correct |
4 ms |
4188 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
2 ms |
860 KB |
Output is correct |
26 |
Correct |
6 ms |
4384 KB |
Output is correct |
27 |
Correct |
6 ms |
4244 KB |
Output is correct |
28 |
Correct |
4 ms |
4188 KB |
Output is correct |
29 |
Correct |
9 ms |
7004 KB |
Output is correct |
30 |
Correct |
3 ms |
736 KB |
Output is correct |
31 |
Correct |
10 ms |
7500 KB |
Output is correct |
32 |
Correct |
12 ms |
7004 KB |
Output is correct |
33 |
Correct |
10 ms |
7004 KB |
Output is correct |
34 |
Correct |
4 ms |
1456 KB |
Output is correct |
35 |
Correct |
4 ms |
1416 KB |
Output is correct |
36 |
Correct |
12 ms |
7088 KB |
Output is correct |
37 |
Correct |
13 ms |
7004 KB |
Output is correct |
38 |
Correct |
9 ms |
7004 KB |
Output is correct |
39 |
Runtime error |
18 ms |
10076 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
864 KB |
Output is correct |
12 |
Correct |
2 ms |
944 KB |
Output is correct |
13 |
Correct |
2 ms |
860 KB |
Output is correct |
14 |
Correct |
2 ms |
1116 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
464 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
604 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
0 ms |
860 KB |
Output is correct |
32 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
860 KB |
Output is correct |
8 |
Correct |
0 ms |
860 KB |
Output is correct |
9 |
Correct |
2 ms |
860 KB |
Output is correct |
10 |
Correct |
2 ms |
856 KB |
Output is correct |
11 |
Correct |
2 ms |
860 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
456 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
1 ms |
860 KB |
Output is correct |
24 |
Correct |
4 ms |
980 KB |
Output is correct |
25 |
Correct |
6 ms |
1628 KB |
Output is correct |
26 |
Correct |
13 ms |
1880 KB |
Output is correct |
27 |
Correct |
4 ms |
4444 KB |
Output is correct |
28 |
Execution timed out |
2098 ms |
4692 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
864 KB |
Output is correct |
12 |
Correct |
2 ms |
944 KB |
Output is correct |
13 |
Correct |
2 ms |
860 KB |
Output is correct |
14 |
Correct |
2 ms |
1116 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
464 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
604 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
0 ms |
860 KB |
Output is correct |
32 |
Correct |
1 ms |
860 KB |
Output is correct |
33 |
Correct |
5 ms |
4184 KB |
Output is correct |
34 |
Correct |
4 ms |
856 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
6 ms |
1628 KB |
Output is correct |
37 |
Correct |
1 ms |
764 KB |
Output is correct |
38 |
Correct |
13 ms |
1968 KB |
Output is correct |
39 |
Correct |
4 ms |
4444 KB |
Output is correct |
40 |
Correct |
6 ms |
4352 KB |
Output is correct |
41 |
Correct |
4 ms |
4188 KB |
Output is correct |
42 |
Execution timed out |
2049 ms |
4904 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
864 KB |
Output is correct |
12 |
Correct |
2 ms |
944 KB |
Output is correct |
13 |
Correct |
2 ms |
860 KB |
Output is correct |
14 |
Correct |
2 ms |
1116 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
464 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
604 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
0 ms |
860 KB |
Output is correct |
32 |
Correct |
1 ms |
860 KB |
Output is correct |
33 |
Correct |
5 ms |
4184 KB |
Output is correct |
34 |
Correct |
4 ms |
856 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
6 ms |
1628 KB |
Output is correct |
37 |
Correct |
1 ms |
764 KB |
Output is correct |
38 |
Correct |
13 ms |
1968 KB |
Output is correct |
39 |
Correct |
4 ms |
4444 KB |
Output is correct |
40 |
Correct |
6 ms |
4352 KB |
Output is correct |
41 |
Correct |
4 ms |
4188 KB |
Output is correct |
42 |
Execution timed out |
2049 ms |
4904 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
860 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
860 KB |
Output is correct |
18 |
Correct |
0 ms |
860 KB |
Output is correct |
19 |
Correct |
4 ms |
4188 KB |
Output is correct |
20 |
Correct |
1 ms |
628 KB |
Output is correct |
21 |
Correct |
4 ms |
4696 KB |
Output is correct |
22 |
Correct |
6 ms |
4188 KB |
Output is correct |
23 |
Correct |
4 ms |
4188 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
2 ms |
860 KB |
Output is correct |
26 |
Correct |
6 ms |
4384 KB |
Output is correct |
27 |
Correct |
6 ms |
4244 KB |
Output is correct |
28 |
Correct |
4 ms |
4188 KB |
Output is correct |
29 |
Correct |
9 ms |
7004 KB |
Output is correct |
30 |
Correct |
3 ms |
736 KB |
Output is correct |
31 |
Correct |
10 ms |
7500 KB |
Output is correct |
32 |
Correct |
12 ms |
7004 KB |
Output is correct |
33 |
Correct |
10 ms |
7004 KB |
Output is correct |
34 |
Correct |
4 ms |
1456 KB |
Output is correct |
35 |
Correct |
4 ms |
1416 KB |
Output is correct |
36 |
Correct |
12 ms |
7088 KB |
Output is correct |
37 |
Correct |
13 ms |
7004 KB |
Output is correct |
38 |
Correct |
9 ms |
7004 KB |
Output is correct |
39 |
Runtime error |
18 ms |
10076 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
860 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
860 KB |
Output is correct |
18 |
Correct |
0 ms |
860 KB |
Output is correct |
19 |
Correct |
4 ms |
4188 KB |
Output is correct |
20 |
Correct |
1 ms |
628 KB |
Output is correct |
21 |
Correct |
4 ms |
4696 KB |
Output is correct |
22 |
Correct |
6 ms |
4188 KB |
Output is correct |
23 |
Correct |
4 ms |
4188 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
2 ms |
860 KB |
Output is correct |
26 |
Correct |
6 ms |
4384 KB |
Output is correct |
27 |
Correct |
6 ms |
4244 KB |
Output is correct |
28 |
Correct |
4 ms |
4188 KB |
Output is correct |
29 |
Correct |
9 ms |
7004 KB |
Output is correct |
30 |
Correct |
3 ms |
736 KB |
Output is correct |
31 |
Correct |
10 ms |
7500 KB |
Output is correct |
32 |
Correct |
12 ms |
7004 KB |
Output is correct |
33 |
Correct |
10 ms |
7004 KB |
Output is correct |
34 |
Correct |
4 ms |
1456 KB |
Output is correct |
35 |
Correct |
4 ms |
1416 KB |
Output is correct |
36 |
Correct |
12 ms |
7088 KB |
Output is correct |
37 |
Correct |
13 ms |
7004 KB |
Output is correct |
38 |
Correct |
9 ms |
7004 KB |
Output is correct |
39 |
Runtime error |
18 ms |
10076 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
360 KB |
Output is correct |
3 |
Correct |
0 ms |
860 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
856 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
860 KB |
Output is correct |
18 |
Correct |
0 ms |
860 KB |
Output is correct |
19 |
Correct |
4 ms |
4188 KB |
Output is correct |
20 |
Correct |
1 ms |
628 KB |
Output is correct |
21 |
Correct |
4 ms |
4696 KB |
Output is correct |
22 |
Correct |
6 ms |
4188 KB |
Output is correct |
23 |
Correct |
4 ms |
4188 KB |
Output is correct |
24 |
Correct |
2 ms |
860 KB |
Output is correct |
25 |
Correct |
2 ms |
860 KB |
Output is correct |
26 |
Correct |
6 ms |
4384 KB |
Output is correct |
27 |
Correct |
6 ms |
4244 KB |
Output is correct |
28 |
Correct |
4 ms |
4188 KB |
Output is correct |
29 |
Correct |
9 ms |
7004 KB |
Output is correct |
30 |
Correct |
3 ms |
736 KB |
Output is correct |
31 |
Correct |
10 ms |
7500 KB |
Output is correct |
32 |
Correct |
12 ms |
7004 KB |
Output is correct |
33 |
Correct |
10 ms |
7004 KB |
Output is correct |
34 |
Correct |
4 ms |
1456 KB |
Output is correct |
35 |
Correct |
4 ms |
1416 KB |
Output is correct |
36 |
Correct |
12 ms |
7088 KB |
Output is correct |
37 |
Correct |
13 ms |
7004 KB |
Output is correct |
38 |
Correct |
9 ms |
7004 KB |
Output is correct |
39 |
Runtime error |
18 ms |
10076 KB |
Execution killed with signal 11 |
40 |
Halted |
0 ms |
0 KB |
- |