Submission #1061526

# Submission time Handle Problem Language Result Execution time Memory
1061526 2024-08-16T10:30:26 Z beaconmc Maze (JOI23_ho_t3) C++14
8 / 100
319 ms 33252 KB
#include <bits/stdc++.h>
 
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
 
using namespace std;

ll r,c,n;



vector<vector<ll>> grid;
vector<vector<bool>> visited;
vector<array<ll, 2>> getvalid(ll a, ll b){
	vector<array<ll, 2>> ans;

	FOR(i,-(n-1), n){
		ans.push_back({a-n, b+i});
		ans.push_back({a+n, b+i});
		ans.push_back({a+i, b-n});
		ans.push_back({a+i, b+n});
	}

	vector<array<ll, 2>> realans;

	for (auto&i : ans){
		if (0<=i[0] && i[0]<r && 0<=i[1] && i[1]<c) realans.push_back(i);
	}

	return realans;
}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> r >> c >> n;

	ll a,b;
	ll x,y;
	cin >> a >> b >> x >> y;
	a--;b--;x--;y--;
	
	FOR(i,0,r){

		vector<ll> temp;
		vector<bool> idk;
		string temp2;
		cin >> temp2;
		FOR(j,0,c){
			temp.push_back(temp2[j]);
			idk.push_back(0);
		}
		grid.push_back(temp);
		visited.push_back(idk);
	}


	ll ans = -1;

	deque<vector<ll>> sus;

	sus.push_back({a,b,0});
	visited[a][b] = 1;
	while (sus.size()){
		vector<ll> node = sus.front();
		sus.pop_front();


		if (node[0] == x && node[1] == y){
			ans = node[2];
			break;
		}


		vector<vector<ll>> pos = {{node[0]-1,node[1]},{node[0]+1,node[1]},{node[0],node[1]-1},{node[0],node[1]+1}};
		for (auto&i : pos){
			if (0<=i[0] && i[0]<r && 0<=i[1] && i[1]<c && !visited[i[0]][i[1]]){
				visited[i[0]][i[1]] = 1;

				if (grid[i[0]][i[1]] == '.') sus.push_front({i[0], i[1], node[2]});
				else sus.push_back({i[0], i[1], node[2]+1});
			}
		}
	}
	cout << ans << endl;








}
# 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 1 ms 348 KB Output is correct
7 Correct 1 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 9 ms 1368 KB Output is correct
20 Correct 7 ms 1236 KB Output is correct
21 Correct 12 ms 2652 KB Output is correct
22 Correct 11 ms 860 KB Output is correct
23 Correct 10 ms 980 KB Output is correct
24 Correct 9 ms 1656 KB Output is correct
25 Correct 8 ms 1492 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 6 ms 860 KB Output is correct
29 Correct 26 ms 1872 KB Output is correct
30 Correct 8 ms 1512 KB Output is correct
31 Correct 15 ms 4060 KB Output is correct
32 Correct 27 ms 1924 KB Output is correct
33 Correct 24 ms 1884 KB Output is correct
34 Correct 28 ms 3160 KB Output is correct
35 Correct 22 ms 3160 KB Output is correct
36 Correct 15 ms 2140 KB Output is correct
37 Correct 22 ms 1884 KB Output is correct
38 Correct 3 ms 1884 KB Output is correct
39 Correct 319 ms 14052 KB Output is correct
40 Correct 10 ms 2012 KB Output is correct
41 Correct 14 ms 3788 KB Output is correct
42 Correct 41 ms 2396 KB Output is correct
43 Correct 31 ms 4704 KB Output is correct
44 Correct 52 ms 9548 KB Output is correct
45 Correct 62 ms 9936 KB Output is correct
46 Correct 290 ms 33252 KB Output is correct
47 Correct 272 ms 14100 KB Output is correct
48 Correct 225 ms 14036 KB Output is correct
49 Correct 175 ms 29680 KB Output is correct
50 Correct 146 ms 29424 KB Output is correct
51 Correct 218 ms 15444 KB Output is correct
52 Correct 145 ms 14684 KB Output is correct
53 Correct 241 ms 14284 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 1 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 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 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 1 ms 348 KB Output is correct
7 Correct 1 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 9 ms 1368 KB Output is correct
20 Correct 7 ms 1236 KB Output is correct
21 Correct 12 ms 2652 KB Output is correct
22 Correct 11 ms 860 KB Output is correct
23 Correct 10 ms 980 KB Output is correct
24 Correct 9 ms 1656 KB Output is correct
25 Correct 8 ms 1492 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 6 ms 860 KB Output is correct
29 Correct 26 ms 1872 KB Output is correct
30 Correct 8 ms 1512 KB Output is correct
31 Correct 15 ms 4060 KB Output is correct
32 Correct 27 ms 1924 KB Output is correct
33 Correct 24 ms 1884 KB Output is correct
34 Correct 28 ms 3160 KB Output is correct
35 Correct 22 ms 3160 KB Output is correct
36 Correct 15 ms 2140 KB Output is correct
37 Correct 22 ms 1884 KB Output is correct
38 Correct 3 ms 1884 KB Output is correct
39 Correct 319 ms 14052 KB Output is correct
40 Correct 10 ms 2012 KB Output is correct
41 Correct 14 ms 3788 KB Output is correct
42 Correct 41 ms 2396 KB Output is correct
43 Correct 31 ms 4704 KB Output is correct
44 Correct 52 ms 9548 KB Output is correct
45 Correct 62 ms 9936 KB Output is correct
46 Correct 290 ms 33252 KB Output is correct
47 Correct 272 ms 14100 KB Output is correct
48 Correct 225 ms 14036 KB Output is correct
49 Correct 175 ms 29680 KB Output is correct
50 Correct 146 ms 29424 KB Output is correct
51 Correct 218 ms 15444 KB Output is correct
52 Correct 145 ms 14684 KB Output is correct
53 Correct 241 ms 14284 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 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 1 ms 348 KB Output is correct
7 Correct 1 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 9 ms 1368 KB Output is correct
20 Correct 7 ms 1236 KB Output is correct
21 Correct 12 ms 2652 KB Output is correct
22 Correct 11 ms 860 KB Output is correct
23 Correct 10 ms 980 KB Output is correct
24 Correct 9 ms 1656 KB Output is correct
25 Correct 8 ms 1492 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 6 ms 860 KB Output is correct
29 Correct 26 ms 1872 KB Output is correct
30 Correct 8 ms 1512 KB Output is correct
31 Correct 15 ms 4060 KB Output is correct
32 Correct 27 ms 1924 KB Output is correct
33 Correct 24 ms 1884 KB Output is correct
34 Correct 28 ms 3160 KB Output is correct
35 Correct 22 ms 3160 KB Output is correct
36 Correct 15 ms 2140 KB Output is correct
37 Correct 22 ms 1884 KB Output is correct
38 Correct 3 ms 1884 KB Output is correct
39 Correct 319 ms 14052 KB Output is correct
40 Correct 10 ms 2012 KB Output is correct
41 Correct 14 ms 3788 KB Output is correct
42 Correct 41 ms 2396 KB Output is correct
43 Correct 31 ms 4704 KB Output is correct
44 Correct 52 ms 9548 KB Output is correct
45 Correct 62 ms 9936 KB Output is correct
46 Correct 290 ms 33252 KB Output is correct
47 Correct 272 ms 14100 KB Output is correct
48 Correct 225 ms 14036 KB Output is correct
49 Correct 175 ms 29680 KB Output is correct
50 Correct 146 ms 29424 KB Output is correct
51 Correct 218 ms 15444 KB Output is correct
52 Correct 145 ms 14684 KB Output is correct
53 Correct 241 ms 14284 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 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 1 ms 348 KB Output is correct
7 Correct 1 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 9 ms 1368 KB Output is correct
20 Correct 7 ms 1236 KB Output is correct
21 Correct 12 ms 2652 KB Output is correct
22 Correct 11 ms 860 KB Output is correct
23 Correct 10 ms 980 KB Output is correct
24 Correct 9 ms 1656 KB Output is correct
25 Correct 8 ms 1492 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 6 ms 860 KB Output is correct
29 Correct 26 ms 1872 KB Output is correct
30 Correct 8 ms 1512 KB Output is correct
31 Correct 15 ms 4060 KB Output is correct
32 Correct 27 ms 1924 KB Output is correct
33 Correct 24 ms 1884 KB Output is correct
34 Correct 28 ms 3160 KB Output is correct
35 Correct 22 ms 3160 KB Output is correct
36 Correct 15 ms 2140 KB Output is correct
37 Correct 22 ms 1884 KB Output is correct
38 Correct 3 ms 1884 KB Output is correct
39 Correct 319 ms 14052 KB Output is correct
40 Correct 10 ms 2012 KB Output is correct
41 Correct 14 ms 3788 KB Output is correct
42 Correct 41 ms 2396 KB Output is correct
43 Correct 31 ms 4704 KB Output is correct
44 Correct 52 ms 9548 KB Output is correct
45 Correct 62 ms 9936 KB Output is correct
46 Correct 290 ms 33252 KB Output is correct
47 Correct 272 ms 14100 KB Output is correct
48 Correct 225 ms 14036 KB Output is correct
49 Correct 175 ms 29680 KB Output is correct
50 Correct 146 ms 29424 KB Output is correct
51 Correct 218 ms 15444 KB Output is correct
52 Correct 145 ms 14684 KB Output is correct
53 Correct 241 ms 14284 KB Output is correct
54 Incorrect 0 ms 348 KB Output isn't correct
55 Halted 0 ms 0 KB -