답안 #948099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948099 2024-03-17T15:16:13 Z 4QT0R Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
516 ms 8356 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>

priority_queue<pii,vector<pii>,greater<pii>> pq;
vector<ll> doges[30002];
bool vis[30002];
ll jmp[30002];
ll odl[30002];
ll n,m,oo=1e14;

void Dijkstra(ll pos, ll kon){
	fill(odl,odl+n,oo);
	odl[pos]=0;
	pq.push({0,pos});
	ll iter;
	while(pq.size()){
		auto [d,v]=pq.top();
		pq.pop();
		if (d>odl[v])continue;
		if (v==kon)break;
		for (auto u : doges[v]) if (!vis[u]){
			vis[u]=true;
			iter=1;
			for (ll i = v+jmp[u]; i<n; i+=jmp[u]){
				if (odl[i]>d+iter){
					odl[i]=d+iter;
					pq.push({d+iter,i});
				}
				iter++;
			}
			iter=1;
			for (ll i = v-jmp[u]; i>=0; i-=jmp[u]){
				if (odl[i]>d+iter){
					odl[i]=d+iter;
					pq.push({d+iter,i});
				}
				iter++;
			}
		}
	}
	if (odl[kon]==oo)cout << "-1\n";
	else cout << odl[kon] << '\n';
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll b,p,st,nd;
	cin >> n >> m;
	cin >> st >> jmp[1];
	doges[st].push_back(1);
	cin >> nd >> p;
	for (ll i = 2; i<m; i++){
		cin >> b >> jmp[i];
		doges[b].push_back(i);
	}
	Dijkstra(st,nd);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1112 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1112 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1220 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 3 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1368 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1368 KB Output is correct
25 Correct 1 ms 1112 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 2 ms 1500 KB Output is correct
30 Correct 1 ms 1372 KB Output is correct
31 Correct 1 ms 1368 KB Output is correct
32 Correct 1 ms 1372 KB Output is correct
33 Correct 2 ms 1628 KB Output is correct
34 Correct 2 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1112 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 4 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 2 ms 1500 KB Output is correct
30 Correct 1 ms 1372 KB Output is correct
31 Correct 1 ms 1372 KB Output is correct
32 Correct 1 ms 1372 KB Output is correct
33 Correct 2 ms 1452 KB Output is correct
34 Correct 2 ms 1628 KB Output is correct
35 Correct 5 ms 1884 KB Output is correct
36 Correct 1 ms 1112 KB Output is correct
37 Correct 4 ms 1628 KB Output is correct
38 Correct 5 ms 1884 KB Output is correct
39 Correct 5 ms 1884 KB Output is correct
40 Correct 5 ms 1884 KB Output is correct
41 Correct 5 ms 1884 KB Output is correct
42 Correct 4 ms 1756 KB Output is correct
43 Correct 3 ms 1756 KB Output is correct
44 Correct 40 ms 1796 KB Output is correct
45 Correct 6 ms 2140 KB Output is correct
46 Correct 5 ms 2260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1368 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1112 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 4 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1120 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1124 KB Output is correct
25 Correct 2 ms 1124 KB Output is correct
26 Correct 1 ms 1124 KB Output is correct
27 Correct 1 ms 1124 KB Output is correct
28 Correct 1 ms 1120 KB Output is correct
29 Correct 2 ms 1500 KB Output is correct
30 Correct 1 ms 1372 KB Output is correct
31 Correct 1 ms 1368 KB Output is correct
32 Correct 1 ms 1372 KB Output is correct
33 Correct 2 ms 1628 KB Output is correct
34 Correct 2 ms 1628 KB Output is correct
35 Correct 5 ms 1884 KB Output is correct
36 Correct 2 ms 1116 KB Output is correct
37 Correct 4 ms 1624 KB Output is correct
38 Correct 5 ms 1884 KB Output is correct
39 Correct 5 ms 1768 KB Output is correct
40 Correct 5 ms 1884 KB Output is correct
41 Correct 5 ms 1884 KB Output is correct
42 Correct 5 ms 1756 KB Output is correct
43 Correct 4 ms 1752 KB Output is correct
44 Correct 42 ms 1796 KB Output is correct
45 Correct 6 ms 2392 KB Output is correct
46 Correct 5 ms 2184 KB Output is correct
47 Correct 8 ms 3044 KB Output is correct
48 Correct 5 ms 1884 KB Output is correct
49 Correct 4 ms 2008 KB Output is correct
50 Correct 4 ms 1880 KB Output is correct
51 Correct 13 ms 4308 KB Output is correct
52 Correct 12 ms 3288 KB Output is correct
53 Correct 7 ms 2648 KB Output is correct
54 Correct 2 ms 1756 KB Output is correct
55 Correct 2 ms 1680 KB Output is correct
56 Correct 516 ms 3036 KB Output is correct
57 Correct 3 ms 2768 KB Output is correct
58 Correct 473 ms 2496 KB Output is correct
59 Correct 6 ms 2392 KB Output is correct
60 Correct 6 ms 2396 KB Output is correct
61 Correct 6 ms 2524 KB Output is correct
62 Correct 7 ms 2888 KB Output is correct
63 Correct 26 ms 4560 KB Output is correct
64 Correct 27 ms 7636 KB Output is correct
65 Correct 31 ms 6600 KB Output is correct
66 Correct 44 ms 8356 KB Output is correct
67 Correct 38 ms 7376 KB Output is correct