# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83334 | 2018-11-07T07:35:01 Z | farukkastamonuda | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 233 ms | 66236 KB |
#include <bits/stdc++.h> #define li 30005 #define inf 2000001000 #define md 1000000007 #define lo long long #define fi first #define se second #define mp make_pair #define pb push_back #define ii pair<lo int,lo int> using namespace std; int n,m,B[li],P[li],dist[li]; set<int> S[li]; vector< pair<int,int> > v[li]; int vis[li]; priority_queue< pair<int,int> > q; void bfs(){ for(int i=0;i<n;i++) dist[i]=inf; q.push(mp(0,B[0])); dist[B[0]]=0; while(!q.empty()){ ii temp=q.top(); q.pop(); int seh=temp.se; int cst=-temp.fi; if(dist[seh]<cst) continue; for(int i=0;i<(int)v[seh].size();i++){ int go=v[seh][i].fi; int para=v[seh][i].se; if(dist[go]>dist[seh]+para){ dist[go]=dist[seh]+para; q.push(mp(-(dist[go]),go)); } } } } int main(){ scanf("%d %d",&n,&m); for(int i=0;i<m;i++){ scanf("%d %d",&B[i],&P[i]); S[B[i]].insert(P[i]); } for(int i=0;i<n;i++){ for(auto e:S[i]){ for(int j=i+e;j<n;j+=e){ v[i].pb(mp(j,(j-i)/e)); if(S[j].lower_bound(e)!=S[j].end() && *S[j].lower_bound(e)==e) break; } } } for(int i=0;i<n;i++){ for(auto e:S[i]){ for(int j=i-e;j>=0;j-=e){ v[i].pb(mp(j,(i-j)/e)); if(S[j].lower_bound(e)!=S[j].end() && *S[j].lower_bound(e)==e) break; } } } bfs(); if(dist[B[1]]==inf) printf("-1\n"); else printf("%d\n",dist[B[1]]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2424 KB | Output is correct |
2 | Correct | 4 ms | 2548 KB | Output is correct |
3 | Correct | 4 ms | 2548 KB | Output is correct |
4 | Correct | 4 ms | 2548 KB | Output is correct |
5 | Correct | 4 ms | 2564 KB | Output is correct |
6 | Correct | 4 ms | 2564 KB | Output is correct |
7 | Correct | 4 ms | 2564 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2564 KB | Output is correct |
2 | Correct | 4 ms | 2564 KB | Output is correct |
3 | Correct | 5 ms | 2564 KB | Output is correct |
4 | Correct | 4 ms | 2684 KB | Output is correct |
5 | Correct | 4 ms | 2684 KB | Output is correct |
6 | Correct | 4 ms | 2684 KB | Output is correct |
7 | Correct | 4 ms | 2684 KB | Output is correct |
8 | Correct | 4 ms | 2740 KB | Output is correct |
9 | Correct | 4 ms | 2740 KB | Output is correct |
10 | Correct | 4 ms | 2740 KB | Output is correct |
11 | Correct | 5 ms | 2756 KB | Output is correct |
12 | Correct | 4 ms | 2756 KB | Output is correct |
13 | Correct | 4 ms | 2768 KB | Output is correct |
14 | Correct | 5 ms | 2788 KB | Output is correct |
15 | Correct | 5 ms | 2788 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2788 KB | Output is correct |
2 | Correct | 4 ms | 2788 KB | Output is correct |
3 | Correct | 4 ms | 2788 KB | Output is correct |
4 | Correct | 4 ms | 2788 KB | Output is correct |
5 | Correct | 4 ms | 2788 KB | Output is correct |
6 | Correct | 4 ms | 2788 KB | Output is correct |
7 | Correct | 4 ms | 2788 KB | Output is correct |
8 | Correct | 4 ms | 2788 KB | Output is correct |
9 | Correct | 4 ms | 2788 KB | Output is correct |
10 | Correct | 4 ms | 2788 KB | Output is correct |
11 | Correct | 5 ms | 2812 KB | Output is correct |
12 | Correct | 4 ms | 2812 KB | Output is correct |
13 | Correct | 4 ms | 2812 KB | Output is correct |
14 | Correct | 5 ms | 2812 KB | Output is correct |
15 | Correct | 5 ms | 2812 KB | Output is correct |
16 | Correct | 4 ms | 2812 KB | Output is correct |
17 | Correct | 5 ms | 2940 KB | Output is correct |
18 | Correct | 5 ms | 2940 KB | Output is correct |
19 | Correct | 4 ms | 2940 KB | Output is correct |
20 | Correct | 5 ms | 2940 KB | Output is correct |
21 | Correct | 5 ms | 2940 KB | Output is correct |
22 | Correct | 5 ms | 2940 KB | Output is correct |
23 | Correct | 5 ms | 2940 KB | Output is correct |
24 | Correct | 5 ms | 2940 KB | Output is correct |
25 | Correct | 5 ms | 2940 KB | Output is correct |
26 | Correct | 4 ms | 2940 KB | Output is correct |
27 | Correct | 5 ms | 2940 KB | Output is correct |
28 | Correct | 5 ms | 3136 KB | Output is correct |
29 | Correct | 6 ms | 3520 KB | Output is correct |
30 | Correct | 5 ms | 3520 KB | Output is correct |
31 | Correct | 7 ms | 3520 KB | Output is correct |
32 | Correct | 6 ms | 3520 KB | Output is correct |
33 | Correct | 9 ms | 4092 KB | Output is correct |
34 | Correct | 9 ms | 4092 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4092 KB | Output is correct |
2 | Correct | 4 ms | 4092 KB | Output is correct |
3 | Correct | 4 ms | 4092 KB | Output is correct |
4 | Correct | 4 ms | 4092 KB | Output is correct |
5 | Correct | 4 ms | 4092 KB | Output is correct |
6 | Correct | 4 ms | 4092 KB | Output is correct |
7 | Correct | 5 ms | 4092 KB | Output is correct |
8 | Correct | 4 ms | 4092 KB | Output is correct |
9 | Correct | 4 ms | 4092 KB | Output is correct |
10 | Correct | 4 ms | 4092 KB | Output is correct |
11 | Correct | 5 ms | 4092 KB | Output is correct |
12 | Correct | 4 ms | 4092 KB | Output is correct |
13 | Correct | 4 ms | 4092 KB | Output is correct |
14 | Correct | 5 ms | 4092 KB | Output is correct |
15 | Correct | 5 ms | 4092 KB | Output is correct |
16 | Correct | 4 ms | 4092 KB | Output is correct |
17 | Correct | 5 ms | 4092 KB | Output is correct |
18 | Correct | 4 ms | 4092 KB | Output is correct |
19 | Correct | 4 ms | 4092 KB | Output is correct |
20 | Correct | 5 ms | 4092 KB | Output is correct |
21 | Correct | 5 ms | 4092 KB | Output is correct |
22 | Correct | 6 ms | 4092 KB | Output is correct |
23 | Correct | 4 ms | 4092 KB | Output is correct |
24 | Correct | 5 ms | 4092 KB | Output is correct |
25 | Correct | 6 ms | 4092 KB | Output is correct |
26 | Correct | 5 ms | 4092 KB | Output is correct |
27 | Correct | 4 ms | 4092 KB | Output is correct |
28 | Correct | 7 ms | 4092 KB | Output is correct |
29 | Correct | 7 ms | 4092 KB | Output is correct |
30 | Correct | 5 ms | 4092 KB | Output is correct |
31 | Correct | 6 ms | 4092 KB | Output is correct |
32 | Correct | 5 ms | 4092 KB | Output is correct |
33 | Correct | 9 ms | 4092 KB | Output is correct |
34 | Correct | 9 ms | 4092 KB | Output is correct |
35 | Correct | 27 ms | 5112 KB | Output is correct |
36 | Correct | 7 ms | 5112 KB | Output is correct |
37 | Correct | 32 ms | 5884 KB | Output is correct |
38 | Correct | 36 ms | 6140 KB | Output is correct |
39 | Correct | 35 ms | 6140 KB | Output is correct |
40 | Correct | 39 ms | 6180 KB | Output is correct |
41 | Correct | 36 ms | 6180 KB | Output is correct |
42 | Correct | 10 ms | 6180 KB | Output is correct |
43 | Correct | 10 ms | 6180 KB | Output is correct |
44 | Correct | 13 ms | 6180 KB | Output is correct |
45 | Correct | 37 ms | 8812 KB | Output is correct |
46 | Correct | 34 ms | 8812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8812 KB | Output is correct |
2 | Correct | 4 ms | 8812 KB | Output is correct |
3 | Correct | 4 ms | 8812 KB | Output is correct |
4 | Correct | 4 ms | 8812 KB | Output is correct |
5 | Correct | 4 ms | 8812 KB | Output is correct |
6 | Correct | 4 ms | 8812 KB | Output is correct |
7 | Correct | 4 ms | 8812 KB | Output is correct |
8 | Correct | 4 ms | 8812 KB | Output is correct |
9 | Correct | 4 ms | 8812 KB | Output is correct |
10 | Correct | 4 ms | 8812 KB | Output is correct |
11 | Correct | 5 ms | 8812 KB | Output is correct |
12 | Correct | 4 ms | 8812 KB | Output is correct |
13 | Correct | 4 ms | 8812 KB | Output is correct |
14 | Correct | 4 ms | 8812 KB | Output is correct |
15 | Correct | 5 ms | 8812 KB | Output is correct |
16 | Correct | 4 ms | 8812 KB | Output is correct |
17 | Correct | 6 ms | 8812 KB | Output is correct |
18 | Correct | 4 ms | 8812 KB | Output is correct |
19 | Correct | 4 ms | 8812 KB | Output is correct |
20 | Correct | 4 ms | 8812 KB | Output is correct |
21 | Correct | 4 ms | 8812 KB | Output is correct |
22 | Correct | 4 ms | 8812 KB | Output is correct |
23 | Correct | 5 ms | 8812 KB | Output is correct |
24 | Correct | 6 ms | 8812 KB | Output is correct |
25 | Correct | 5 ms | 8812 KB | Output is correct |
26 | Correct | 4 ms | 8812 KB | Output is correct |
27 | Correct | 4 ms | 8812 KB | Output is correct |
28 | Correct | 5 ms | 8812 KB | Output is correct |
29 | Correct | 6 ms | 8812 KB | Output is correct |
30 | Correct | 5 ms | 8812 KB | Output is correct |
31 | Correct | 5 ms | 8812 KB | Output is correct |
32 | Correct | 5 ms | 8812 KB | Output is correct |
33 | Correct | 9 ms | 8812 KB | Output is correct |
34 | Correct | 9 ms | 8812 KB | Output is correct |
35 | Correct | 41 ms | 8812 KB | Output is correct |
36 | Correct | 7 ms | 8812 KB | Output is correct |
37 | Correct | 33 ms | 8812 KB | Output is correct |
38 | Correct | 34 ms | 8812 KB | Output is correct |
39 | Correct | 35 ms | 8812 KB | Output is correct |
40 | Correct | 35 ms | 8812 KB | Output is correct |
41 | Correct | 36 ms | 8812 KB | Output is correct |
42 | Correct | 10 ms | 8812 KB | Output is correct |
43 | Correct | 10 ms | 8812 KB | Output is correct |
44 | Correct | 10 ms | 8812 KB | Output is correct |
45 | Correct | 35 ms | 8812 KB | Output is correct |
46 | Correct | 36 ms | 8812 KB | Output is correct |
47 | Correct | 73 ms | 13332 KB | Output is correct |
48 | Correct | 26 ms | 13332 KB | Output is correct |
49 | Correct | 21 ms | 13332 KB | Output is correct |
50 | Correct | 16 ms | 13332 KB | Output is correct |
51 | Correct | 55 ms | 13332 KB | Output is correct |
52 | Correct | 60 ms | 13332 KB | Output is correct |
53 | Correct | 27 ms | 13332 KB | Output is correct |
54 | Correct | 6 ms | 13332 KB | Output is correct |
55 | Correct | 7 ms | 13332 KB | Output is correct |
56 | Correct | 20 ms | 13332 KB | Output is correct |
57 | Correct | 49 ms | 13332 KB | Output is correct |
58 | Correct | 14 ms | 13332 KB | Output is correct |
59 | Correct | 15 ms | 13332 KB | Output is correct |
60 | Correct | 17 ms | 13332 KB | Output is correct |
61 | Correct | 16 ms | 13332 KB | Output is correct |
62 | Correct | 33 ms | 13332 KB | Output is correct |
63 | Correct | 93 ms | 25868 KB | Output is correct |
64 | Correct | 109 ms | 28756 KB | Output is correct |
65 | Correct | 136 ms | 38776 KB | Output is correct |
66 | Correct | 233 ms | 66024 KB | Output is correct |
67 | Correct | 226 ms | 66236 KB | Output is correct |