답안 #924148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924148 2024-02-08T14:25:51 Z vjudge1 Maze (JOI23_ho_t3) C++17
8 / 100
67 ms 73588 KB
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(ll i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define imp(v) for(auto edu:v)cout<<edu<<" "; cout<<"\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const ll MAXN=6e6+5;

ll a[MAXN];
ll n,m,k;
ll cv(ii x){return m*x.fst+x.snd;}
ii cv(ll x){return {x/m,x%m};}
vector<ii>dir={{0,1},{-1,0},{0,-1},{1,0}};
ii operator+(ii a, ii b){return {a.fst+b.fst,a.snd+b.snd};}
bool allowed(ii p){
	auto [i,j]=p;
	if(i<0||i>=n||j<0||j>=m)return 0;
	return 1;
}
ll d[MAXN];
void bfs(ii s){
	mset(d,-1);
	deque<ii>q;
	d[cv(s)]=0;
	q.push_front(s);
	while(SZ(q)){
		auto x=q.front(); q.pop_front();
		for(auto add:dir){
			auto y=x+add;
			if(!allowed(y)||d[cv(y)]!=-1)continue;
			if(a[cv(y)])q.pb(y),d[cv(y)]=d[cv(x)]+1;
			else q.push_front(y),d[cv(y)]=d[cv(x)];
		}
		/*if(a[cv(x)]){
			
		}*/
	}
}

int main(){FIN;
	cin>>n>>m>>k;
	ii s,e; cin>>s.fst>>s.snd>>e.fst>>e.snd; s.fst--,s.snd--,e.fst--,e.snd--;
	fore(i,0,n*m){
		char c; cin>>c;
		a[i]=(c=='#');
	}
	bfs(s);
	cout<<d[cv(e)]<<"\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 47708 KB Output is correct
2 Correct 7 ms 47820 KB Output is correct
3 Correct 6 ms 47708 KB Output is correct
4 Correct 7 ms 47840 KB Output is correct
5 Correct 6 ms 47708 KB Output is correct
6 Correct 6 ms 47708 KB Output is correct
7 Correct 7 ms 47788 KB Output is correct
8 Correct 6 ms 47708 KB Output is correct
9 Correct 6 ms 47708 KB Output is correct
10 Correct 6 ms 47708 KB Output is correct
11 Correct 6 ms 47708 KB Output is correct
12 Correct 6 ms 47708 KB Output is correct
13 Correct 7 ms 47708 KB Output is correct
14 Correct 7 ms 47784 KB Output is correct
15 Correct 6 ms 47704 KB Output is correct
16 Correct 6 ms 47704 KB Output is correct
17 Correct 7 ms 47708 KB Output is correct
18 Correct 6 ms 47824 KB Output is correct
19 Correct 8 ms 49756 KB Output is correct
20 Correct 7 ms 47892 KB Output is correct
21 Correct 9 ms 50268 KB Output is correct
22 Correct 9 ms 49884 KB Output is correct
23 Correct 9 ms 49756 KB Output is correct
24 Correct 8 ms 49756 KB Output is correct
25 Correct 8 ms 49756 KB Output is correct
26 Correct 9 ms 50012 KB Output is correct
27 Correct 8 ms 49932 KB Output is correct
28 Correct 9 ms 50012 KB Output is correct
29 Correct 11 ms 50012 KB Output is correct
30 Correct 8 ms 49756 KB Output is correct
31 Correct 12 ms 51292 KB Output is correct
32 Correct 12 ms 50012 KB Output is correct
33 Correct 11 ms 49892 KB Output is correct
34 Correct 10 ms 50012 KB Output is correct
35 Correct 9 ms 49992 KB Output is correct
36 Correct 12 ms 50012 KB Output is correct
37 Correct 12 ms 50012 KB Output is correct
38 Correct 13 ms 50012 KB Output is correct
39 Correct 56 ms 61184 KB Output is correct
40 Correct 13 ms 50012 KB Output is correct
41 Correct 12 ms 50064 KB Output is correct
42 Correct 14 ms 49896 KB Output is correct
43 Correct 15 ms 50008 KB Output is correct
44 Correct 31 ms 54508 KB Output is correct
45 Correct 32 ms 54620 KB Output is correct
46 Correct 60 ms 73588 KB Output is correct
47 Correct 64 ms 60992 KB Output is correct
48 Correct 54 ms 61012 KB Output is correct
49 Correct 38 ms 61008 KB Output is correct
50 Correct 41 ms 61152 KB Output is correct
51 Correct 61 ms 61520 KB Output is correct
52 Correct 67 ms 61368 KB Output is correct
53 Correct 53 ms 61020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 47808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 47708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 47808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 47808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 47708 KB Output is correct
2 Correct 7 ms 47820 KB Output is correct
3 Correct 6 ms 47708 KB Output is correct
4 Correct 7 ms 47840 KB Output is correct
5 Correct 6 ms 47708 KB Output is correct
6 Correct 6 ms 47708 KB Output is correct
7 Correct 7 ms 47788 KB Output is correct
8 Correct 6 ms 47708 KB Output is correct
9 Correct 6 ms 47708 KB Output is correct
10 Correct 6 ms 47708 KB Output is correct
11 Correct 6 ms 47708 KB Output is correct
12 Correct 6 ms 47708 KB Output is correct
13 Correct 7 ms 47708 KB Output is correct
14 Correct 7 ms 47784 KB Output is correct
15 Correct 6 ms 47704 KB Output is correct
16 Correct 6 ms 47704 KB Output is correct
17 Correct 7 ms 47708 KB Output is correct
18 Correct 6 ms 47824 KB Output is correct
19 Correct 8 ms 49756 KB Output is correct
20 Correct 7 ms 47892 KB Output is correct
21 Correct 9 ms 50268 KB Output is correct
22 Correct 9 ms 49884 KB Output is correct
23 Correct 9 ms 49756 KB Output is correct
24 Correct 8 ms 49756 KB Output is correct
25 Correct 8 ms 49756 KB Output is correct
26 Correct 9 ms 50012 KB Output is correct
27 Correct 8 ms 49932 KB Output is correct
28 Correct 9 ms 50012 KB Output is correct
29 Correct 11 ms 50012 KB Output is correct
30 Correct 8 ms 49756 KB Output is correct
31 Correct 12 ms 51292 KB Output is correct
32 Correct 12 ms 50012 KB Output is correct
33 Correct 11 ms 49892 KB Output is correct
34 Correct 10 ms 50012 KB Output is correct
35 Correct 9 ms 49992 KB Output is correct
36 Correct 12 ms 50012 KB Output is correct
37 Correct 12 ms 50012 KB Output is correct
38 Correct 13 ms 50012 KB Output is correct
39 Correct 56 ms 61184 KB Output is correct
40 Correct 13 ms 50012 KB Output is correct
41 Correct 12 ms 50064 KB Output is correct
42 Correct 14 ms 49896 KB Output is correct
43 Correct 15 ms 50008 KB Output is correct
44 Correct 31 ms 54508 KB Output is correct
45 Correct 32 ms 54620 KB Output is correct
46 Correct 60 ms 73588 KB Output is correct
47 Correct 64 ms 60992 KB Output is correct
48 Correct 54 ms 61012 KB Output is correct
49 Correct 38 ms 61008 KB Output is correct
50 Correct 41 ms 61152 KB Output is correct
51 Correct 61 ms 61520 KB Output is correct
52 Correct 67 ms 61368 KB Output is correct
53 Correct 53 ms 61020 KB Output is correct
54 Incorrect 7 ms 47808 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 47708 KB Output is correct
2 Correct 7 ms 47820 KB Output is correct
3 Correct 6 ms 47708 KB Output is correct
4 Correct 7 ms 47840 KB Output is correct
5 Correct 6 ms 47708 KB Output is correct
6 Correct 6 ms 47708 KB Output is correct
7 Correct 7 ms 47788 KB Output is correct
8 Correct 6 ms 47708 KB Output is correct
9 Correct 6 ms 47708 KB Output is correct
10 Correct 6 ms 47708 KB Output is correct
11 Correct 6 ms 47708 KB Output is correct
12 Correct 6 ms 47708 KB Output is correct
13 Correct 7 ms 47708 KB Output is correct
14 Correct 7 ms 47784 KB Output is correct
15 Correct 6 ms 47704 KB Output is correct
16 Correct 6 ms 47704 KB Output is correct
17 Correct 7 ms 47708 KB Output is correct
18 Correct 6 ms 47824 KB Output is correct
19 Correct 8 ms 49756 KB Output is correct
20 Correct 7 ms 47892 KB Output is correct
21 Correct 9 ms 50268 KB Output is correct
22 Correct 9 ms 49884 KB Output is correct
23 Correct 9 ms 49756 KB Output is correct
24 Correct 8 ms 49756 KB Output is correct
25 Correct 8 ms 49756 KB Output is correct
26 Correct 9 ms 50012 KB Output is correct
27 Correct 8 ms 49932 KB Output is correct
28 Correct 9 ms 50012 KB Output is correct
29 Correct 11 ms 50012 KB Output is correct
30 Correct 8 ms 49756 KB Output is correct
31 Correct 12 ms 51292 KB Output is correct
32 Correct 12 ms 50012 KB Output is correct
33 Correct 11 ms 49892 KB Output is correct
34 Correct 10 ms 50012 KB Output is correct
35 Correct 9 ms 49992 KB Output is correct
36 Correct 12 ms 50012 KB Output is correct
37 Correct 12 ms 50012 KB Output is correct
38 Correct 13 ms 50012 KB Output is correct
39 Correct 56 ms 61184 KB Output is correct
40 Correct 13 ms 50012 KB Output is correct
41 Correct 12 ms 50064 KB Output is correct
42 Correct 14 ms 49896 KB Output is correct
43 Correct 15 ms 50008 KB Output is correct
44 Correct 31 ms 54508 KB Output is correct
45 Correct 32 ms 54620 KB Output is correct
46 Correct 60 ms 73588 KB Output is correct
47 Correct 64 ms 60992 KB Output is correct
48 Correct 54 ms 61012 KB Output is correct
49 Correct 38 ms 61008 KB Output is correct
50 Correct 41 ms 61152 KB Output is correct
51 Correct 61 ms 61520 KB Output is correct
52 Correct 67 ms 61368 KB Output is correct
53 Correct 53 ms 61020 KB Output is correct
54 Incorrect 7 ms 47808 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 47708 KB Output is correct
2 Correct 7 ms 47820 KB Output is correct
3 Correct 6 ms 47708 KB Output is correct
4 Correct 7 ms 47840 KB Output is correct
5 Correct 6 ms 47708 KB Output is correct
6 Correct 6 ms 47708 KB Output is correct
7 Correct 7 ms 47788 KB Output is correct
8 Correct 6 ms 47708 KB Output is correct
9 Correct 6 ms 47708 KB Output is correct
10 Correct 6 ms 47708 KB Output is correct
11 Correct 6 ms 47708 KB Output is correct
12 Correct 6 ms 47708 KB Output is correct
13 Correct 7 ms 47708 KB Output is correct
14 Correct 7 ms 47784 KB Output is correct
15 Correct 6 ms 47704 KB Output is correct
16 Correct 6 ms 47704 KB Output is correct
17 Correct 7 ms 47708 KB Output is correct
18 Correct 6 ms 47824 KB Output is correct
19 Correct 8 ms 49756 KB Output is correct
20 Correct 7 ms 47892 KB Output is correct
21 Correct 9 ms 50268 KB Output is correct
22 Correct 9 ms 49884 KB Output is correct
23 Correct 9 ms 49756 KB Output is correct
24 Correct 8 ms 49756 KB Output is correct
25 Correct 8 ms 49756 KB Output is correct
26 Correct 9 ms 50012 KB Output is correct
27 Correct 8 ms 49932 KB Output is correct
28 Correct 9 ms 50012 KB Output is correct
29 Correct 11 ms 50012 KB Output is correct
30 Correct 8 ms 49756 KB Output is correct
31 Correct 12 ms 51292 KB Output is correct
32 Correct 12 ms 50012 KB Output is correct
33 Correct 11 ms 49892 KB Output is correct
34 Correct 10 ms 50012 KB Output is correct
35 Correct 9 ms 49992 KB Output is correct
36 Correct 12 ms 50012 KB Output is correct
37 Correct 12 ms 50012 KB Output is correct
38 Correct 13 ms 50012 KB Output is correct
39 Correct 56 ms 61184 KB Output is correct
40 Correct 13 ms 50012 KB Output is correct
41 Correct 12 ms 50064 KB Output is correct
42 Correct 14 ms 49896 KB Output is correct
43 Correct 15 ms 50008 KB Output is correct
44 Correct 31 ms 54508 KB Output is correct
45 Correct 32 ms 54620 KB Output is correct
46 Correct 60 ms 73588 KB Output is correct
47 Correct 64 ms 60992 KB Output is correct
48 Correct 54 ms 61012 KB Output is correct
49 Correct 38 ms 61008 KB Output is correct
50 Correct 41 ms 61152 KB Output is correct
51 Correct 61 ms 61520 KB Output is correct
52 Correct 67 ms 61368 KB Output is correct
53 Correct 53 ms 61020 KB Output is correct
54 Incorrect 7 ms 47808 KB Output isn't correct
55 Halted 0 ms 0 KB -