# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
895934 |
2023-12-31T06:51:30 Z |
niter |
Maze (JOI23_ho_t3) |
C++14 |
|
271 ms |
15004 KB |
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
using namespace std;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }
inline bool check(int i, int j, int n, int m){
return i >= 0 && j >= 0 && i < n && j < m;
}
const int INF = (int)(1e9);
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
vector<vector<char>> c;
vector<vector<int>> dis;
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
pii s, t;
cin >> s.ff >> s.ss >> t.ff >> t.ss;
s.ff--; s.ss--; t.ff--; t.ss--;
c = vector<vector<char>>(n, vector<char>(m, ' '));
loop(i,0,n){
loop(j,0,m){
cin >> c[i][j];
}
}
priority_queue<pair<int,pii>, vector<pair<int,pii>>, greater<pair<int,pii>>> pq;
pq.push({0, s});
dis = vector<vector<int>>(n, vector<int>(m, INF));
dis[s.ff][s.ss] = 0;
while(!pq.empty()){
int nowx = pq.top().ss.ff;
int nowy = pq.top().ss.ss;
int nowd = pq.top().ff;
pq.pop();
if(nowd != dis[nowx][nowy]) continue;
loop(d,0,4){
int nx = nowx + dx[d];
int ny = nowy + dy[d];
if(!check(nx, ny, n, m)) continue;
if(dis[nx][ny] > nowd + (c[nx][ny] == '#')){
dis[nx][ny] = nowd + (c[nx][ny] == '#');
pq.push({dis[nx][ny], {nx, ny}});
}
}
}
cout << dis[t.ff][t.ss] << '\n';
}
/*
*/
Compilation message
Main.cpp: In function 'std::ostream& operator<<(std::ostream&, std::pair<int, int>)':
Main.cpp:16:84: warning: no return statement in function returning non-void [-Wreturn-type]
16 | ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
464 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
8 ms |
604 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
7 ms |
860 KB |
Output is correct |
22 |
Correct |
9 ms |
876 KB |
Output is correct |
23 |
Correct |
6 ms |
604 KB |
Output is correct |
24 |
Correct |
2 ms |
1116 KB |
Output is correct |
25 |
Correct |
2 ms |
984 KB |
Output is correct |
26 |
Correct |
10 ms |
860 KB |
Output is correct |
27 |
Correct |
10 ms |
840 KB |
Output is correct |
28 |
Correct |
7 ms |
860 KB |
Output is correct |
29 |
Correct |
18 ms |
1400 KB |
Output is correct |
30 |
Correct |
4 ms |
860 KB |
Output is correct |
31 |
Correct |
16 ms |
1384 KB |
Output is correct |
32 |
Correct |
23 ms |
1368 KB |
Output is correct |
33 |
Correct |
17 ms |
1368 KB |
Output is correct |
34 |
Correct |
5 ms |
1736 KB |
Output is correct |
35 |
Correct |
6 ms |
1736 KB |
Output is correct |
36 |
Correct |
25 ms |
1372 KB |
Output is correct |
37 |
Correct |
24 ms |
1368 KB |
Output is correct |
38 |
Correct |
18 ms |
1372 KB |
Output is correct |
39 |
Correct |
194 ms |
9308 KB |
Output is correct |
40 |
Correct |
20 ms |
1372 KB |
Output is correct |
41 |
Correct |
7 ms |
2080 KB |
Output is correct |
42 |
Correct |
27 ms |
1628 KB |
Output is correct |
43 |
Correct |
12 ms |
2392 KB |
Output is correct |
44 |
Correct |
90 ms |
5212 KB |
Output is correct |
45 |
Correct |
65 ms |
5816 KB |
Output is correct |
46 |
Correct |
192 ms |
9552 KB |
Output is correct |
47 |
Correct |
229 ms |
9432 KB |
Output is correct |
48 |
Correct |
189 ms |
9296 KB |
Output is correct |
49 |
Correct |
45 ms |
15004 KB |
Output is correct |
50 |
Correct |
47 ms |
15000 KB |
Output is correct |
51 |
Correct |
271 ms |
10088 KB |
Output is correct |
52 |
Correct |
248 ms |
9556 KB |
Output is correct |
53 |
Correct |
199 ms |
9512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
464 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
8 ms |
604 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
7 ms |
860 KB |
Output is correct |
22 |
Correct |
9 ms |
876 KB |
Output is correct |
23 |
Correct |
6 ms |
604 KB |
Output is correct |
24 |
Correct |
2 ms |
1116 KB |
Output is correct |
25 |
Correct |
2 ms |
984 KB |
Output is correct |
26 |
Correct |
10 ms |
860 KB |
Output is correct |
27 |
Correct |
10 ms |
840 KB |
Output is correct |
28 |
Correct |
7 ms |
860 KB |
Output is correct |
29 |
Correct |
18 ms |
1400 KB |
Output is correct |
30 |
Correct |
4 ms |
860 KB |
Output is correct |
31 |
Correct |
16 ms |
1384 KB |
Output is correct |
32 |
Correct |
23 ms |
1368 KB |
Output is correct |
33 |
Correct |
17 ms |
1368 KB |
Output is correct |
34 |
Correct |
5 ms |
1736 KB |
Output is correct |
35 |
Correct |
6 ms |
1736 KB |
Output is correct |
36 |
Correct |
25 ms |
1372 KB |
Output is correct |
37 |
Correct |
24 ms |
1368 KB |
Output is correct |
38 |
Correct |
18 ms |
1372 KB |
Output is correct |
39 |
Correct |
194 ms |
9308 KB |
Output is correct |
40 |
Correct |
20 ms |
1372 KB |
Output is correct |
41 |
Correct |
7 ms |
2080 KB |
Output is correct |
42 |
Correct |
27 ms |
1628 KB |
Output is correct |
43 |
Correct |
12 ms |
2392 KB |
Output is correct |
44 |
Correct |
90 ms |
5212 KB |
Output is correct |
45 |
Correct |
65 ms |
5816 KB |
Output is correct |
46 |
Correct |
192 ms |
9552 KB |
Output is correct |
47 |
Correct |
229 ms |
9432 KB |
Output is correct |
48 |
Correct |
189 ms |
9296 KB |
Output is correct |
49 |
Correct |
45 ms |
15004 KB |
Output is correct |
50 |
Correct |
47 ms |
15000 KB |
Output is correct |
51 |
Correct |
271 ms |
10088 KB |
Output is correct |
52 |
Correct |
248 ms |
9556 KB |
Output is correct |
53 |
Correct |
199 ms |
9512 KB |
Output is correct |
54 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
55 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
464 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
8 ms |
604 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
7 ms |
860 KB |
Output is correct |
22 |
Correct |
9 ms |
876 KB |
Output is correct |
23 |
Correct |
6 ms |
604 KB |
Output is correct |
24 |
Correct |
2 ms |
1116 KB |
Output is correct |
25 |
Correct |
2 ms |
984 KB |
Output is correct |
26 |
Correct |
10 ms |
860 KB |
Output is correct |
27 |
Correct |
10 ms |
840 KB |
Output is correct |
28 |
Correct |
7 ms |
860 KB |
Output is correct |
29 |
Correct |
18 ms |
1400 KB |
Output is correct |
30 |
Correct |
4 ms |
860 KB |
Output is correct |
31 |
Correct |
16 ms |
1384 KB |
Output is correct |
32 |
Correct |
23 ms |
1368 KB |
Output is correct |
33 |
Correct |
17 ms |
1368 KB |
Output is correct |
34 |
Correct |
5 ms |
1736 KB |
Output is correct |
35 |
Correct |
6 ms |
1736 KB |
Output is correct |
36 |
Correct |
25 ms |
1372 KB |
Output is correct |
37 |
Correct |
24 ms |
1368 KB |
Output is correct |
38 |
Correct |
18 ms |
1372 KB |
Output is correct |
39 |
Correct |
194 ms |
9308 KB |
Output is correct |
40 |
Correct |
20 ms |
1372 KB |
Output is correct |
41 |
Correct |
7 ms |
2080 KB |
Output is correct |
42 |
Correct |
27 ms |
1628 KB |
Output is correct |
43 |
Correct |
12 ms |
2392 KB |
Output is correct |
44 |
Correct |
90 ms |
5212 KB |
Output is correct |
45 |
Correct |
65 ms |
5816 KB |
Output is correct |
46 |
Correct |
192 ms |
9552 KB |
Output is correct |
47 |
Correct |
229 ms |
9432 KB |
Output is correct |
48 |
Correct |
189 ms |
9296 KB |
Output is correct |
49 |
Correct |
45 ms |
15004 KB |
Output is correct |
50 |
Correct |
47 ms |
15000 KB |
Output is correct |
51 |
Correct |
271 ms |
10088 KB |
Output is correct |
52 |
Correct |
248 ms |
9556 KB |
Output is correct |
53 |
Correct |
199 ms |
9512 KB |
Output is correct |
54 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
55 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 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 |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
464 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
600 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
8 ms |
604 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
7 ms |
860 KB |
Output is correct |
22 |
Correct |
9 ms |
876 KB |
Output is correct |
23 |
Correct |
6 ms |
604 KB |
Output is correct |
24 |
Correct |
2 ms |
1116 KB |
Output is correct |
25 |
Correct |
2 ms |
984 KB |
Output is correct |
26 |
Correct |
10 ms |
860 KB |
Output is correct |
27 |
Correct |
10 ms |
840 KB |
Output is correct |
28 |
Correct |
7 ms |
860 KB |
Output is correct |
29 |
Correct |
18 ms |
1400 KB |
Output is correct |
30 |
Correct |
4 ms |
860 KB |
Output is correct |
31 |
Correct |
16 ms |
1384 KB |
Output is correct |
32 |
Correct |
23 ms |
1368 KB |
Output is correct |
33 |
Correct |
17 ms |
1368 KB |
Output is correct |
34 |
Correct |
5 ms |
1736 KB |
Output is correct |
35 |
Correct |
6 ms |
1736 KB |
Output is correct |
36 |
Correct |
25 ms |
1372 KB |
Output is correct |
37 |
Correct |
24 ms |
1368 KB |
Output is correct |
38 |
Correct |
18 ms |
1372 KB |
Output is correct |
39 |
Correct |
194 ms |
9308 KB |
Output is correct |
40 |
Correct |
20 ms |
1372 KB |
Output is correct |
41 |
Correct |
7 ms |
2080 KB |
Output is correct |
42 |
Correct |
27 ms |
1628 KB |
Output is correct |
43 |
Correct |
12 ms |
2392 KB |
Output is correct |
44 |
Correct |
90 ms |
5212 KB |
Output is correct |
45 |
Correct |
65 ms |
5816 KB |
Output is correct |
46 |
Correct |
192 ms |
9552 KB |
Output is correct |
47 |
Correct |
229 ms |
9432 KB |
Output is correct |
48 |
Correct |
189 ms |
9296 KB |
Output is correct |
49 |
Correct |
45 ms |
15004 KB |
Output is correct |
50 |
Correct |
47 ms |
15000 KB |
Output is correct |
51 |
Correct |
271 ms |
10088 KB |
Output is correct |
52 |
Correct |
248 ms |
9556 KB |
Output is correct |
53 |
Correct |
199 ms |
9512 KB |
Output is correct |
54 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
55 |
Halted |
0 ms |
0 KB |
- |