Submission #741066

# Submission time Handle Problem Language Result Execution time Memory
741066 2023-05-13T13:46:58 Z emptypringlescan Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
263 ms 260468 KB
#include <bits/stdc++.h>
using namespace std;
int cor[30005][3];
vector<pair<int,int> > adj[7000000];
int32_t main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	int c=30001;
	for(int i=0; i<n; i++){
		for(int j=1; j<3; j++){
			cor[i][j]=c;
			c++;
		}
	}
	for(int i=0; i<n; i++){
		for(int j=1; j<3; j++){
			if(i+j<n){
				adj[cor[i][j]].push_back({cor[i+j][j],1});
				adj[cor[i+j][j]].push_back({cor[i][j],1});
			}
			adj[cor[i][j]].push_back({i,0});
		}
	}
	
	int s=0,e=0;
	for(int i=0; i<m; i++){
		int a,b;
		cin >> a >> b;
		if(i==0) s=a;
		if(i==1) e=a;
		if(b<3){
			adj[a].push_back({cor[a][b],0});
		}
		else{
			for(int j=1; j<n; j++){
				if(a+j*b>=n) break;
				adj[a].push_back({a+j*b,j});
			}
			for(int j=1; j<n; j++){
				if(a-j*b<0) break;
				adj[a].push_back({a-j*b,j});
			}
		}
	}
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
	pq.push({0,s});
	int dist[5000000];
	for(int i=0; i<5000000; i++) dist[i]=1e7;
	dist[s]=0;
	while(!pq.empty()){
		int a=pq.top().first,b=pq.top().second;
		pq.pop();
		if(a>dist[b]) continue;
		//cout << b << ' ' << a << '\n';
		if(b==e){
			cout << a;
			return 0;
		}
		for(auto i:adj[b]){
			if(dist[i.first]<=a+i.second) continue;
			dist[i.first]=a+i.second;
			pq.push({a+i.second,i.first});
		}
	}
	cout << -1;
}
# Verdict Execution time Memory Grader output
1 Correct 84 ms 184140 KB Output is correct
2 Correct 85 ms 184184 KB Output is correct
3 Correct 86 ms 184160 KB Output is correct
4 Correct 86 ms 184224 KB Output is correct
5 Correct 92 ms 184260 KB Output is correct
6 Correct 92 ms 184172 KB Output is correct
7 Correct 85 ms 184176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 184340 KB Output is correct
2 Correct 87 ms 184148 KB Output is correct
3 Correct 88 ms 184140 KB Output is correct
4 Correct 100 ms 184176 KB Output is correct
5 Correct 97 ms 184212 KB Output is correct
6 Correct 86 ms 184140 KB Output is correct
7 Correct 86 ms 184260 KB Output is correct
8 Correct 86 ms 184208 KB Output is correct
9 Correct 87 ms 184320 KB Output is correct
10 Correct 91 ms 184188 KB Output is correct
11 Correct 91 ms 184268 KB Output is correct
12 Correct 88 ms 184224 KB Output is correct
13 Correct 88 ms 184192 KB Output is correct
14 Correct 87 ms 184268 KB Output is correct
15 Correct 100 ms 184312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 184248 KB Output is correct
2 Correct 85 ms 184236 KB Output is correct
3 Correct 86 ms 184172 KB Output is correct
4 Correct 87 ms 184244 KB Output is correct
5 Correct 88 ms 184256 KB Output is correct
6 Correct 85 ms 184144 KB Output is correct
7 Correct 84 ms 184256 KB Output is correct
8 Correct 93 ms 184260 KB Output is correct
9 Correct 85 ms 184216 KB Output is correct
10 Correct 87 ms 184200 KB Output is correct
11 Correct 86 ms 184336 KB Output is correct
12 Correct 93 ms 184208 KB Output is correct
13 Correct 94 ms 184304 KB Output is correct
14 Correct 89 ms 184264 KB Output is correct
15 Correct 90 ms 184256 KB Output is correct
16 Correct 86 ms 184272 KB Output is correct
17 Correct 88 ms 184648 KB Output is correct
18 Correct 86 ms 184524 KB Output is correct
19 Correct 87 ms 184532 KB Output is correct
20 Correct 89 ms 184480 KB Output is correct
21 Correct 88 ms 184320 KB Output is correct
22 Correct 90 ms 184464 KB Output is correct
23 Correct 95 ms 184448 KB Output is correct
24 Correct 94 ms 184676 KB Output is correct
25 Correct 94 ms 184488 KB Output is correct
26 Correct 90 ms 184536 KB Output is correct
27 Correct 101 ms 184512 KB Output is correct
28 Correct 92 ms 184640 KB Output is correct
29 Correct 89 ms 185164 KB Output is correct
30 Correct 87 ms 184704 KB Output is correct
31 Correct 87 ms 184872 KB Output is correct
32 Correct 86 ms 184636 KB Output is correct
33 Correct 89 ms 185932 KB Output is correct
34 Correct 90 ms 185752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 184248 KB Output is correct
2 Correct 98 ms 184296 KB Output is correct
3 Correct 93 ms 184260 KB Output is correct
4 Correct 88 ms 184268 KB Output is correct
5 Correct 88 ms 184200 KB Output is correct
6 Correct 86 ms 184252 KB Output is correct
7 Correct 83 ms 184184 KB Output is correct
8 Correct 86 ms 184264 KB Output is correct
9 Correct 89 ms 184280 KB Output is correct
10 Correct 86 ms 184168 KB Output is correct
11 Correct 88 ms 184324 KB Output is correct
12 Correct 88 ms 184392 KB Output is correct
13 Correct 88 ms 184300 KB Output is correct
14 Correct 83 ms 184316 KB Output is correct
15 Correct 93 ms 184312 KB Output is correct
16 Correct 101 ms 184336 KB Output is correct
17 Correct 92 ms 184532 KB Output is correct
18 Correct 88 ms 184516 KB Output is correct
19 Correct 90 ms 184640 KB Output is correct
20 Correct 90 ms 184540 KB Output is correct
21 Correct 90 ms 184324 KB Output is correct
22 Correct 89 ms 184448 KB Output is correct
23 Correct 89 ms 184516 KB Output is correct
24 Correct 89 ms 184636 KB Output is correct
25 Correct 92 ms 184520 KB Output is correct
26 Correct 87 ms 184488 KB Output is correct
27 Correct 92 ms 184440 KB Output is correct
28 Correct 90 ms 184684 KB Output is correct
29 Correct 100 ms 185188 KB Output is correct
30 Correct 116 ms 184620 KB Output is correct
31 Correct 100 ms 184908 KB Output is correct
32 Correct 88 ms 184668 KB Output is correct
33 Correct 97 ms 185872 KB Output is correct
34 Correct 93 ms 185836 KB Output is correct
35 Correct 95 ms 185804 KB Output is correct
36 Correct 87 ms 184584 KB Output is correct
37 Correct 92 ms 187408 KB Output is correct
38 Correct 99 ms 187012 KB Output is correct
39 Correct 115 ms 186948 KB Output is correct
40 Correct 96 ms 186912 KB Output is correct
41 Correct 95 ms 186888 KB Output is correct
42 Correct 95 ms 185112 KB Output is correct
43 Correct 92 ms 185040 KB Output is correct
44 Correct 95 ms 185032 KB Output is correct
45 Correct 117 ms 189472 KB Output is correct
46 Correct 103 ms 189516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 184208 KB Output is correct
2 Correct 89 ms 184240 KB Output is correct
3 Correct 88 ms 184168 KB Output is correct
4 Correct 92 ms 184256 KB Output is correct
5 Correct 86 ms 184192 KB Output is correct
6 Correct 89 ms 184164 KB Output is correct
7 Correct 98 ms 184140 KB Output is correct
8 Correct 90 ms 184228 KB Output is correct
9 Correct 91 ms 184264 KB Output is correct
10 Correct 95 ms 184240 KB Output is correct
11 Correct 97 ms 184352 KB Output is correct
12 Correct 89 ms 184192 KB Output is correct
13 Correct 89 ms 184260 KB Output is correct
14 Correct 100 ms 184276 KB Output is correct
15 Correct 96 ms 184268 KB Output is correct
16 Correct 86 ms 184424 KB Output is correct
17 Correct 89 ms 184444 KB Output is correct
18 Correct 87 ms 184396 KB Output is correct
19 Correct 92 ms 184400 KB Output is correct
20 Correct 95 ms 184528 KB Output is correct
21 Correct 85 ms 184268 KB Output is correct
22 Correct 87 ms 184376 KB Output is correct
23 Correct 87 ms 184424 KB Output is correct
24 Correct 95 ms 184652 KB Output is correct
25 Correct 94 ms 184540 KB Output is correct
26 Correct 101 ms 184596 KB Output is correct
27 Correct 111 ms 184532 KB Output is correct
28 Correct 94 ms 184640 KB Output is correct
29 Correct 91 ms 185240 KB Output is correct
30 Correct 92 ms 184652 KB Output is correct
31 Correct 91 ms 184856 KB Output is correct
32 Correct 87 ms 184644 KB Output is correct
33 Correct 97 ms 185852 KB Output is correct
34 Correct 107 ms 185784 KB Output is correct
35 Correct 104 ms 185884 KB Output is correct
36 Correct 93 ms 184472 KB Output is correct
37 Correct 96 ms 187372 KB Output is correct
38 Correct 95 ms 186972 KB Output is correct
39 Correct 98 ms 186844 KB Output is correct
40 Correct 98 ms 186956 KB Output is correct
41 Correct 96 ms 186948 KB Output is correct
42 Correct 91 ms 185168 KB Output is correct
43 Correct 90 ms 185024 KB Output is correct
44 Correct 96 ms 184996 KB Output is correct
45 Correct 162 ms 189508 KB Output is correct
46 Correct 98 ms 189480 KB Output is correct
47 Correct 115 ms 195756 KB Output is correct
48 Correct 109 ms 189172 KB Output is correct
49 Correct 114 ms 188664 KB Output is correct
50 Correct 110 ms 188620 KB Output is correct
51 Correct 114 ms 191464 KB Output is correct
52 Correct 117 ms 191548 KB Output is correct
53 Correct 106 ms 187896 KB Output is correct
54 Correct 97 ms 187404 KB Output is correct
55 Correct 97 ms 187596 KB Output is correct
56 Correct 103 ms 188528 KB Output is correct
57 Correct 172 ms 245092 KB Output is correct
58 Correct 107 ms 188268 KB Output is correct
59 Correct 98 ms 188868 KB Output is correct
60 Correct 99 ms 189532 KB Output is correct
61 Correct 113 ms 188592 KB Output is correct
62 Correct 117 ms 192216 KB Output is correct
63 Correct 150 ms 212372 KB Output is correct
64 Correct 153 ms 220136 KB Output is correct
65 Correct 176 ms 226380 KB Output is correct
66 Correct 240 ms 258696 KB Output is correct
67 Correct 263 ms 260468 KB Output is correct