Submission #270671

# Submission time Handle Problem Language Result Execution time Memory
270671 2020-08-17T21:42:56 Z test2 Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
242 ms 70752 KB
#include<bits/stdc++.h>

#define I inline void 

using ll = long long ; 
using ld = long double ; 

using namespace std ; 

const int N = 1e5 + 7 , mod = 1e9+7 ;  

// how interesting!

int n;  
int d[N] ; 
vector<pair<int , int > > adj[N] ;
bool skys[30001][30001] , ed[30001][30001]; 

int st , en ; 

I dijkstra(){

	priority_queue<pair<int , int> > qu ; 
	qu.push({0 , st}) ; 
	d[st] = 0 ; 

	while(qu.size()){
		int dst = -qu.top().first ; 
		int node = qu.top().second ; 
		qu.pop() ; 

		for(auto u : adj[node]){
			if(d[u.first] == -1 || dst + u.second < d[u.first]){

				d[u.first]  = dst + u.second ; 
				qu.push({-d[u.first] , u.first}) ;
			}
		}
	}
}

set<int> sts[N] ; 

int main(){	
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in" , "r" , stdin) ;  
	memset(d , -1 , sizeof d) ; 
	int m; 
	cin >> n >> m; 

	for(int i = 0 ;i < m;i++){
		int a , b; 
		cin >> a >> b; 
		if(i == 0) 
			st = a ;
		if(i == 1 )
			en = a; 
		sts[a].insert(b) ;
	}

	for(int i = 0 ;i < n;i++){
		for(auto u : sts[i]){

			for(int j = 1 ; i + u * j < n ;j ++){
				int cur = i + u * j ; 

				adj[i].push_back({i + u * j , j }) ; 
				if(sts[cur].count(u))
					break ; 

			}

			for(int j = 1 ; i - u * j >=0 ;j ++){
				int cur = i - u * j ; 

				adj[i].push_back({i - u * j , j }) ; 
				if(sts[cur].count(u))
					break ; 
			}	
		}
	}


	dijkstra() ; 
	cout<< d[en] ; 

	return 0 ; 
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7808 KB Output is correct
2 Correct 5 ms 7808 KB Output is correct
3 Correct 5 ms 7808 KB Output is correct
4 Correct 5 ms 7808 KB Output is correct
5 Correct 5 ms 7808 KB Output is correct
6 Correct 5 ms 7808 KB Output is correct
7 Correct 5 ms 7808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7808 KB Output is correct
2 Correct 5 ms 7808 KB Output is correct
3 Correct 5 ms 7808 KB Output is correct
4 Correct 5 ms 7808 KB Output is correct
5 Correct 5 ms 7808 KB Output is correct
6 Correct 5 ms 7808 KB Output is correct
7 Correct 5 ms 7808 KB Output is correct
8 Correct 5 ms 7808 KB Output is correct
9 Correct 5 ms 7808 KB Output is correct
10 Correct 5 ms 7808 KB Output is correct
11 Correct 6 ms 7936 KB Output is correct
12 Correct 6 ms 7808 KB Output is correct
13 Correct 5 ms 7808 KB Output is correct
14 Correct 6 ms 7936 KB Output is correct
15 Correct 6 ms 7936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 7808 KB Output is correct
2 Correct 5 ms 7808 KB Output is correct
3 Correct 5 ms 7808 KB Output is correct
4 Correct 5 ms 7808 KB Output is correct
5 Correct 5 ms 7808 KB Output is correct
6 Correct 5 ms 7808 KB Output is correct
7 Correct 5 ms 7808 KB Output is correct
8 Correct 5 ms 7808 KB Output is correct
9 Correct 5 ms 7808 KB Output is correct
10 Correct 5 ms 7808 KB Output is correct
11 Correct 6 ms 7936 KB Output is correct
12 Correct 5 ms 7808 KB Output is correct
13 Correct 6 ms 7808 KB Output is correct
14 Correct 6 ms 7936 KB Output is correct
15 Correct 6 ms 7936 KB Output is correct
16 Correct 6 ms 7808 KB Output is correct
17 Correct 7 ms 8064 KB Output is correct
18 Correct 6 ms 7936 KB Output is correct
19 Correct 7 ms 7808 KB Output is correct
20 Correct 6 ms 7936 KB Output is correct
21 Correct 6 ms 7808 KB Output is correct
22 Correct 6 ms 7936 KB Output is correct
23 Correct 6 ms 7936 KB Output is correct
24 Correct 8 ms 8064 KB Output is correct
25 Correct 7 ms 8064 KB Output is correct
26 Correct 7 ms 7936 KB Output is correct
27 Correct 6 ms 7936 KB Output is correct
28 Correct 7 ms 8064 KB Output is correct
29 Correct 10 ms 8576 KB Output is correct
30 Correct 6 ms 8064 KB Output is correct
31 Correct 9 ms 8192 KB Output is correct
32 Correct 8 ms 8064 KB Output is correct
33 Correct 10 ms 9212 KB Output is correct
34 Correct 11 ms 9212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7808 KB Output is correct
2 Correct 5 ms 7808 KB Output is correct
3 Correct 6 ms 7808 KB Output is correct
4 Correct 5 ms 7808 KB Output is correct
5 Correct 5 ms 7808 KB Output is correct
6 Correct 5 ms 7808 KB Output is correct
7 Correct 5 ms 7712 KB Output is correct
8 Correct 5 ms 7712 KB Output is correct
9 Correct 5 ms 7808 KB Output is correct
10 Correct 5 ms 7808 KB Output is correct
11 Correct 6 ms 7936 KB Output is correct
12 Correct 5 ms 7808 KB Output is correct
13 Correct 6 ms 7808 KB Output is correct
14 Correct 6 ms 7936 KB Output is correct
15 Correct 6 ms 7936 KB Output is correct
16 Correct 6 ms 7808 KB Output is correct
17 Correct 7 ms 8064 KB Output is correct
18 Correct 6 ms 7936 KB Output is correct
19 Correct 5 ms 7808 KB Output is correct
20 Correct 6 ms 7936 KB Output is correct
21 Correct 6 ms 7808 KB Output is correct
22 Correct 6 ms 7936 KB Output is correct
23 Correct 6 ms 7936 KB Output is correct
24 Correct 7 ms 8064 KB Output is correct
25 Correct 7 ms 8064 KB Output is correct
26 Correct 6 ms 7936 KB Output is correct
27 Correct 7 ms 7936 KB Output is correct
28 Correct 6 ms 8064 KB Output is correct
29 Correct 8 ms 8576 KB Output is correct
30 Correct 6 ms 8064 KB Output is correct
31 Correct 8 ms 8192 KB Output is correct
32 Correct 7 ms 8064 KB Output is correct
33 Correct 10 ms 9212 KB Output is correct
34 Correct 10 ms 9212 KB Output is correct
35 Correct 23 ms 9984 KB Output is correct
36 Correct 8 ms 8192 KB Output is correct
37 Correct 27 ms 10752 KB Output is correct
38 Correct 30 ms 11004 KB Output is correct
39 Correct 30 ms 11000 KB Output is correct
40 Correct 30 ms 11008 KB Output is correct
41 Correct 31 ms 11000 KB Output is correct
42 Correct 10 ms 8064 KB Output is correct
43 Correct 10 ms 8064 KB Output is correct
44 Correct 10 ms 8192 KB Output is correct
45 Correct 38 ms 13736 KB Output is correct
46 Correct 33 ms 13696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7808 KB Output is correct
2 Correct 5 ms 7808 KB Output is correct
3 Correct 5 ms 7808 KB Output is correct
4 Correct 5 ms 7808 KB Output is correct
5 Correct 5 ms 7808 KB Output is correct
6 Correct 5 ms 7808 KB Output is correct
7 Correct 5 ms 7808 KB Output is correct
8 Correct 5 ms 7808 KB Output is correct
9 Correct 5 ms 7808 KB Output is correct
10 Correct 5 ms 7808 KB Output is correct
11 Correct 8 ms 7936 KB Output is correct
12 Correct 5 ms 7808 KB Output is correct
13 Correct 6 ms 7808 KB Output is correct
14 Correct 7 ms 7936 KB Output is correct
15 Correct 7 ms 7936 KB Output is correct
16 Correct 6 ms 7808 KB Output is correct
17 Correct 8 ms 8064 KB Output is correct
18 Correct 6 ms 7936 KB Output is correct
19 Correct 6 ms 7808 KB Output is correct
20 Correct 6 ms 7936 KB Output is correct
21 Correct 6 ms 7808 KB Output is correct
22 Correct 6 ms 7936 KB Output is correct
23 Correct 7 ms 7936 KB Output is correct
24 Correct 7 ms 8064 KB Output is correct
25 Correct 8 ms 8192 KB Output is correct
26 Correct 6 ms 7936 KB Output is correct
27 Correct 6 ms 7936 KB Output is correct
28 Correct 7 ms 8064 KB Output is correct
29 Correct 8 ms 8576 KB Output is correct
30 Correct 6 ms 8064 KB Output is correct
31 Correct 7 ms 8192 KB Output is correct
32 Correct 7 ms 8064 KB Output is correct
33 Correct 11 ms 9340 KB Output is correct
34 Correct 11 ms 9212 KB Output is correct
35 Correct 23 ms 9984 KB Output is correct
36 Correct 8 ms 8192 KB Output is correct
37 Correct 26 ms 10752 KB Output is correct
38 Correct 30 ms 11008 KB Output is correct
39 Correct 31 ms 11000 KB Output is correct
40 Correct 30 ms 11008 KB Output is correct
41 Correct 30 ms 11008 KB Output is correct
42 Correct 11 ms 8092 KB Output is correct
43 Correct 10 ms 8064 KB Output is correct
44 Correct 10 ms 8192 KB Output is correct
45 Correct 34 ms 13688 KB Output is correct
46 Correct 35 ms 13816 KB Output is correct
47 Correct 62 ms 18292 KB Output is correct
48 Correct 24 ms 11516 KB Output is correct
49 Correct 26 ms 10488 KB Output is correct
50 Correct 17 ms 10112 KB Output is correct
51 Correct 52 ms 13452 KB Output is correct
52 Correct 56 ms 13944 KB Output is correct
53 Correct 25 ms 11156 KB Output is correct
54 Correct 7 ms 8320 KB Output is correct
55 Correct 9 ms 8700 KB Output is correct
56 Correct 18 ms 10368 KB Output is correct
57 Correct 49 ms 17020 KB Output is correct
58 Correct 13 ms 8952 KB Output is correct
59 Correct 15 ms 9340 KB Output is correct
60 Correct 17 ms 10108 KB Output is correct
61 Correct 16 ms 9468 KB Output is correct
62 Correct 39 ms 14580 KB Output is correct
63 Correct 83 ms 30832 KB Output is correct
64 Correct 91 ms 34160 KB Output is correct
65 Correct 120 ms 43756 KB Output is correct
66 Correct 242 ms 70752 KB Output is correct
67 Correct 241 ms 70752 KB Output is correct