답안 #241449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241449 2020-06-24T08:10:08 Z maximath_1 Jakarta Skyscrapers (APIO15_skyscraper) C++11
100 / 100
227 ms 67940 KB
/*D10-4 (100)*/
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int> >adj[30005];
set<int> building[30005];
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >pq;
int n, m, st, ed, dist[30005];
int ans=1e9+69;
int main(){
	scanf("%d%d", &n, &m);
	int b, p;
	scanf("%d%d", &st, &p); building[st].insert(p);
	scanf("%d%d", &ed, &p); building[ed].insert(p);
	for(int i=2; i<m; i++){
		scanf("%d%d", &b, &p);
		building[b].insert(p);
	}
	for(int i=0; i<n; i++) for(int p:building[i]){
		for(int j=1; i+j*p<n; j++){
			adj[i].push_back({i+j*p, j});
			if(building[i+j*p].count(p)) break;
		}
		for(int j=1; i-j*p>=0; j++){
			adj[i].push_back({i-j*p, j});
			if(building[i-j*p].count(p)) break;
		}
	}
	for(int i=0; i<n; i++) dist[i]=1e9+69;
	pq.push({0, st}); dist[st]=0;
	for(;!pq.empty();){
		int dst=pq.top().first, nw=pq.top().second;
		pq.pop();
		if(dist[nw]!=dst) continue;
		if(nw==ed) ans=min(ans, dst);
		for(pair<int, int> nx:adj[nw]){
			if(dist[nx.first]>dist[nw]+nx.second){
				dist[nx.first]=dist[nw]+nx.second;
				pq.push({dist[nx.first], nx.first});
			}
		}
	}
	if(ans==1e9+69) ans=-1;
	printf("%d\n", ans);
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
skyscraper.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &st, &p); building[st].insert(p);
  ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &ed, &p); building[ed].insert(p);
  ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &b, &p);
   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2432 KB Output is correct
2 Correct 6 ms 2432 KB Output is correct
3 Correct 6 ms 2432 KB Output is correct
4 Correct 6 ms 2432 KB Output is correct
5 Correct 7 ms 2432 KB Output is correct
6 Correct 6 ms 2432 KB Output is correct
7 Correct 6 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2432 KB Output is correct
2 Correct 6 ms 2432 KB Output is correct
3 Correct 6 ms 2432 KB Output is correct
4 Correct 6 ms 2432 KB Output is correct
5 Correct 6 ms 2484 KB Output is correct
6 Correct 6 ms 2432 KB Output is correct
7 Correct 6 ms 2432 KB Output is correct
8 Correct 6 ms 2432 KB Output is correct
9 Correct 6 ms 2432 KB Output is correct
10 Correct 6 ms 2432 KB Output is correct
11 Correct 7 ms 2560 KB Output is correct
12 Correct 6 ms 2432 KB Output is correct
13 Correct 6 ms 2432 KB Output is correct
14 Correct 7 ms 2560 KB Output is correct
15 Correct 8 ms 2560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2432 KB Output is correct
2 Correct 6 ms 2432 KB Output is correct
3 Correct 6 ms 2432 KB Output is correct
4 Correct 6 ms 2432 KB Output is correct
5 Correct 6 ms 2432 KB Output is correct
6 Correct 6 ms 2432 KB Output is correct
7 Correct 6 ms 2432 KB Output is correct
8 Correct 6 ms 2432 KB Output is correct
9 Correct 6 ms 2432 KB Output is correct
10 Correct 6 ms 2432 KB Output is correct
11 Correct 7 ms 2560 KB Output is correct
12 Correct 6 ms 2432 KB Output is correct
13 Correct 6 ms 2432 KB Output is correct
14 Correct 7 ms 2560 KB Output is correct
15 Correct 6 ms 2560 KB Output is correct
16 Correct 6 ms 2560 KB Output is correct
17 Correct 7 ms 2688 KB Output is correct
18 Correct 6 ms 2560 KB Output is correct
19 Correct 6 ms 2560 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2560 KB Output is correct
22 Correct 6 ms 2560 KB Output is correct
23 Correct 7 ms 2560 KB Output is correct
24 Correct 8 ms 2688 KB Output is correct
25 Correct 7 ms 2688 KB Output is correct
26 Correct 7 ms 2560 KB Output is correct
27 Correct 7 ms 2560 KB Output is correct
28 Correct 8 ms 2816 KB Output is correct
29 Correct 9 ms 3328 KB Output is correct
30 Correct 7 ms 2688 KB Output is correct
31 Correct 8 ms 2944 KB Output is correct
32 Correct 7 ms 2816 KB Output is correct
33 Correct 12 ms 4096 KB Output is correct
34 Correct 12 ms 4096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2432 KB Output is correct
2 Correct 6 ms 2432 KB Output is correct
3 Correct 6 ms 2432 KB Output is correct
4 Correct 6 ms 2432 KB Output is correct
5 Correct 6 ms 2432 KB Output is correct
6 Correct 6 ms 2432 KB Output is correct
7 Correct 6 ms 2432 KB Output is correct
8 Correct 6 ms 2432 KB Output is correct
9 Correct 6 ms 2432 KB Output is correct
10 Correct 6 ms 2432 KB Output is correct
11 Correct 7 ms 2560 KB Output is correct
12 Correct 6 ms 2432 KB Output is correct
13 Correct 6 ms 2432 KB Output is correct
14 Correct 7 ms 2560 KB Output is correct
15 Correct 7 ms 2560 KB Output is correct
16 Correct 6 ms 2560 KB Output is correct
17 Correct 8 ms 2688 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
19 Correct 6 ms 2560 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2560 KB Output is correct
22 Correct 6 ms 2560 KB Output is correct
23 Correct 6 ms 2560 KB Output is correct
24 Correct 7 ms 2688 KB Output is correct
25 Correct 7 ms 2688 KB Output is correct
26 Correct 7 ms 2560 KB Output is correct
27 Correct 7 ms 2560 KB Output is correct
28 Correct 9 ms 2816 KB Output is correct
29 Correct 9 ms 3328 KB Output is correct
30 Correct 7 ms 2688 KB Output is correct
31 Correct 7 ms 2944 KB Output is correct
32 Correct 7 ms 2816 KB Output is correct
33 Correct 13 ms 3968 KB Output is correct
34 Correct 12 ms 3968 KB Output is correct
35 Correct 24 ms 4864 KB Output is correct
36 Correct 9 ms 2944 KB Output is correct
37 Correct 25 ms 5632 KB Output is correct
38 Correct 30 ms 5888 KB Output is correct
39 Correct 30 ms 5888 KB Output is correct
40 Correct 30 ms 5880 KB Output is correct
41 Correct 30 ms 5888 KB Output is correct
42 Correct 12 ms 2816 KB Output is correct
43 Correct 12 ms 2688 KB Output is correct
44 Correct 12 ms 2816 KB Output is correct
45 Correct 33 ms 8568 KB Output is correct
46 Correct 32 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2432 KB Output is correct
2 Correct 6 ms 2432 KB Output is correct
3 Correct 6 ms 2432 KB Output is correct
4 Correct 6 ms 2432 KB Output is correct
5 Correct 6 ms 2432 KB Output is correct
6 Correct 6 ms 2432 KB Output is correct
7 Correct 6 ms 2432 KB Output is correct
8 Correct 7 ms 2432 KB Output is correct
9 Correct 6 ms 2432 KB Output is correct
10 Correct 6 ms 2432 KB Output is correct
11 Correct 7 ms 2560 KB Output is correct
12 Correct 6 ms 2432 KB Output is correct
13 Correct 6 ms 2432 KB Output is correct
14 Correct 7 ms 2560 KB Output is correct
15 Correct 7 ms 2560 KB Output is correct
16 Correct 6 ms 2560 KB Output is correct
17 Correct 8 ms 2688 KB Output is correct
18 Correct 6 ms 2560 KB Output is correct
19 Correct 6 ms 2560 KB Output is correct
20 Correct 7 ms 2560 KB Output is correct
21 Correct 6 ms 2560 KB Output is correct
22 Correct 6 ms 2560 KB Output is correct
23 Correct 7 ms 2560 KB Output is correct
24 Correct 7 ms 2688 KB Output is correct
25 Correct 7 ms 2688 KB Output is correct
26 Correct 7 ms 2560 KB Output is correct
27 Correct 8 ms 2560 KB Output is correct
28 Correct 7 ms 2816 KB Output is correct
29 Correct 9 ms 3328 KB Output is correct
30 Correct 7 ms 2816 KB Output is correct
31 Correct 8 ms 2944 KB Output is correct
32 Correct 8 ms 2816 KB Output is correct
33 Correct 12 ms 3968 KB Output is correct
34 Correct 12 ms 4096 KB Output is correct
35 Correct 33 ms 4864 KB Output is correct
36 Correct 9 ms 2816 KB Output is correct
37 Correct 25 ms 5760 KB Output is correct
38 Correct 30 ms 5888 KB Output is correct
39 Correct 30 ms 5884 KB Output is correct
40 Correct 30 ms 5888 KB Output is correct
41 Correct 31 ms 5888 KB Output is correct
42 Correct 12 ms 2816 KB Output is correct
43 Correct 12 ms 2688 KB Output is correct
44 Correct 12 ms 2816 KB Output is correct
45 Correct 35 ms 8576 KB Output is correct
46 Correct 33 ms 8576 KB Output is correct
47 Correct 55 ms 13044 KB Output is correct
48 Correct 25 ms 6172 KB Output is correct
49 Correct 24 ms 5248 KB Output is correct
50 Correct 17 ms 4864 KB Output is correct
51 Correct 50 ms 8196 KB Output is correct
52 Correct 49 ms 8640 KB Output is correct
53 Correct 27 ms 5884 KB Output is correct
54 Correct 8 ms 3072 KB Output is correct
55 Correct 9 ms 3452 KB Output is correct
56 Correct 20 ms 5120 KB Output is correct
57 Correct 42 ms 11644 KB Output is correct
58 Correct 17 ms 3704 KB Output is correct
59 Correct 16 ms 4092 KB Output is correct
60 Correct 19 ms 4860 KB Output is correct
61 Correct 18 ms 4224 KB Output is correct
62 Correct 32 ms 9336 KB Output is correct
63 Correct 89 ms 26608 KB Output is correct
64 Correct 96 ms 29552 KB Output is correct
65 Correct 130 ms 39584 KB Output is correct
66 Correct 227 ms 67788 KB Output is correct
67 Correct 227 ms 67940 KB Output is correct