# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
41702 | 2018-02-20T19:45:09 Z | Hassoony | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 870 ms | 10684 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef double D; const int inf=(1<<30); const int MX=30009; vector<int>v[MX]; int dis[MX],vis[MX]; int n,m,b,p,st,en; int main(){ scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ scanf("%d%d",&b,&p); v[b].push_back(p); if(i==0)st=b; if(i==1)en=b; } for(int i=0;i<n;i++)dis[i]=inf; dis[st]=0; priority_queue<pair<int,int> >pq; pq.push({0,st}); while(!pq.empty()){ int x=pq.top().second,c=-pq.top().first;pq.pop(); if(vis[x])continue; vis[x]=1; for(auto pp:v[x]){ // cout<<pp<<endl; for(int i=1;i*pp+x<n;i++){ // cout<<i*pp+x<<" "; if(dis[i*pp+x]>c+i){ dis[i*pp+x]=c+i; pq.push({-c-i,i*pp+x}); } } for(int i=1;-i*pp+x>=0;i++){ if(dis[-i*pp+x]>c+i){ dis[-i*pp+x]=c+i; pq.push({-c-i,-i*pp+x}); } } } } if(dis[en]==inf)puts("-1"); else cout<<dis[en]<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1016 KB | Output is correct |
2 | Correct | 2 ms | 1212 KB | Output is correct |
3 | Correct | 2 ms | 1212 KB | Output is correct |
4 | Correct | 2 ms | 1212 KB | Output is correct |
5 | Correct | 3 ms | 1212 KB | Output is correct |
6 | Correct | 2 ms | 1212 KB | Output is correct |
7 | Correct | 2 ms | 1212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1212 KB | Output is correct |
2 | Correct | 2 ms | 1212 KB | Output is correct |
3 | Correct | 2 ms | 1212 KB | Output is correct |
4 | Correct | 2 ms | 1212 KB | Output is correct |
5 | Correct | 2 ms | 1212 KB | Output is correct |
6 | Correct | 2 ms | 1212 KB | Output is correct |
7 | Correct | 2 ms | 1212 KB | Output is correct |
8 | Correct | 3 ms | 1212 KB | Output is correct |
9 | Correct | 2 ms | 1212 KB | Output is correct |
10 | Correct | 2 ms | 1240 KB | Output is correct |
11 | Correct | 3 ms | 1244 KB | Output is correct |
12 | Correct | 3 ms | 1244 KB | Output is correct |
13 | Correct | 2 ms | 1244 KB | Output is correct |
14 | Correct | 2 ms | 1244 KB | Output is correct |
15 | Correct | 2 ms | 1248 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1248 KB | Output is correct |
2 | Correct | 2 ms | 1248 KB | Output is correct |
3 | Correct | 2 ms | 1248 KB | Output is correct |
4 | Correct | 2 ms | 1248 KB | Output is correct |
5 | Correct | 2 ms | 1248 KB | Output is correct |
6 | Correct | 2 ms | 1248 KB | Output is correct |
7 | Correct | 2 ms | 1260 KB | Output is correct |
8 | Correct | 2 ms | 1260 KB | Output is correct |
9 | Correct | 2 ms | 1260 KB | Output is correct |
10 | Correct | 2 ms | 1260 KB | Output is correct |
11 | Correct | 2 ms | 1260 KB | Output is correct |
12 | Correct | 3 ms | 1260 KB | Output is correct |
13 | Correct | 2 ms | 1260 KB | Output is correct |
14 | Correct | 2 ms | 1264 KB | Output is correct |
15 | Correct | 3 ms | 1308 KB | Output is correct |
16 | Correct | 2 ms | 1308 KB | Output is correct |
17 | Correct | 3 ms | 1308 KB | Output is correct |
18 | Correct | 2 ms | 1308 KB | Output is correct |
19 | Correct | 2 ms | 1308 KB | Output is correct |
20 | Correct | 6 ms | 1416 KB | Output is correct |
21 | Correct | 3 ms | 1416 KB | Output is correct |
22 | Correct | 2 ms | 1416 KB | Output is correct |
23 | Correct | 2 ms | 1416 KB | Output is correct |
24 | Correct | 3 ms | 1416 KB | Output is correct |
25 | Correct | 3 ms | 1416 KB | Output is correct |
26 | Correct | 6 ms | 1444 KB | Output is correct |
27 | Correct | 6 ms | 1476 KB | Output is correct |
28 | Correct | 3 ms | 1508 KB | Output is correct |
29 | Correct | 3 ms | 1736 KB | Output is correct |
30 | Correct | 3 ms | 1736 KB | Output is correct |
31 | Correct | 3 ms | 1736 KB | Output is correct |
32 | Correct | 3 ms | 1736 KB | Output is correct |
33 | Correct | 3 ms | 1736 KB | Output is correct |
34 | Correct | 4 ms | 1736 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1736 KB | Output is correct |
2 | Correct | 2 ms | 1736 KB | Output is correct |
3 | Correct | 2 ms | 1736 KB | Output is correct |
4 | Correct | 2 ms | 1736 KB | Output is correct |
5 | Correct | 2 ms | 1736 KB | Output is correct |
6 | Correct | 2 ms | 1736 KB | Output is correct |
7 | Correct | 2 ms | 1736 KB | Output is correct |
8 | Correct | 2 ms | 1736 KB | Output is correct |
9 | Correct | 2 ms | 1736 KB | Output is correct |
10 | Correct | 2 ms | 1736 KB | Output is correct |
11 | Correct | 3 ms | 1736 KB | Output is correct |
12 | Correct | 3 ms | 1736 KB | Output is correct |
13 | Correct | 2 ms | 1736 KB | Output is correct |
14 | Correct | 2 ms | 1736 KB | Output is correct |
15 | Correct | 3 ms | 1736 KB | Output is correct |
16 | Correct | 2 ms | 1736 KB | Output is correct |
17 | Correct | 4 ms | 1736 KB | Output is correct |
18 | Correct | 2 ms | 1736 KB | Output is correct |
19 | Correct | 2 ms | 1736 KB | Output is correct |
20 | Correct | 6 ms | 1736 KB | Output is correct |
21 | Correct | 3 ms | 1736 KB | Output is correct |
22 | Correct | 2 ms | 1736 KB | Output is correct |
23 | Correct | 3 ms | 1736 KB | Output is correct |
24 | Correct | 4 ms | 1736 KB | Output is correct |
25 | Correct | 3 ms | 1736 KB | Output is correct |
26 | Correct | 6 ms | 1736 KB | Output is correct |
27 | Correct | 6 ms | 1736 KB | Output is correct |
28 | Correct | 2 ms | 1736 KB | Output is correct |
29 | Correct | 3 ms | 1780 KB | Output is correct |
30 | Correct | 3 ms | 1788 KB | Output is correct |
31 | Correct | 3 ms | 1792 KB | Output is correct |
32 | Correct | 3 ms | 1800 KB | Output is correct |
33 | Correct | 3 ms | 1800 KB | Output is correct |
34 | Correct | 4 ms | 1940 KB | Output is correct |
35 | Correct | 10 ms | 2208 KB | Output is correct |
36 | Correct | 4 ms | 2208 KB | Output is correct |
37 | Correct | 12 ms | 2468 KB | Output is correct |
38 | Correct | 13 ms | 2756 KB | Output is correct |
39 | Correct | 11 ms | 3020 KB | Output is correct |
40 | Correct | 13 ms | 3284 KB | Output is correct |
41 | Correct | 12 ms | 3548 KB | Output is correct |
42 | Correct | 62 ms | 3632 KB | Output is correct |
43 | Correct | 60 ms | 3892 KB | Output is correct |
44 | Correct | 61 ms | 4100 KB | Output is correct |
45 | Correct | 10 ms | 4308 KB | Output is correct |
46 | Correct | 10 ms | 4520 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4520 KB | Output is correct |
2 | Correct | 2 ms | 4520 KB | Output is correct |
3 | Correct | 2 ms | 4520 KB | Output is correct |
4 | Correct | 2 ms | 4520 KB | Output is correct |
5 | Correct | 2 ms | 4520 KB | Output is correct |
6 | Correct | 2 ms | 4520 KB | Output is correct |
7 | Correct | 2 ms | 4520 KB | Output is correct |
8 | Correct | 2 ms | 4520 KB | Output is correct |
9 | Correct | 2 ms | 4520 KB | Output is correct |
10 | Correct | 2 ms | 4520 KB | Output is correct |
11 | Correct | 2 ms | 4520 KB | Output is correct |
12 | Correct | 2 ms | 4520 KB | Output is correct |
13 | Correct | 3 ms | 4520 KB | Output is correct |
14 | Correct | 2 ms | 4520 KB | Output is correct |
15 | Correct | 2 ms | 4520 KB | Output is correct |
16 | Correct | 2 ms | 4520 KB | Output is correct |
17 | Correct | 3 ms | 4520 KB | Output is correct |
18 | Correct | 2 ms | 4520 KB | Output is correct |
19 | Correct | 2 ms | 4520 KB | Output is correct |
20 | Correct | 6 ms | 4520 KB | Output is correct |
21 | Correct | 2 ms | 4520 KB | Output is correct |
22 | Correct | 2 ms | 4520 KB | Output is correct |
23 | Correct | 2 ms | 4520 KB | Output is correct |
24 | Correct | 3 ms | 4520 KB | Output is correct |
25 | Correct | 4 ms | 4520 KB | Output is correct |
26 | Correct | 6 ms | 4520 KB | Output is correct |
27 | Correct | 5 ms | 4520 KB | Output is correct |
28 | Correct | 2 ms | 4520 KB | Output is correct |
29 | Correct | 3 ms | 4520 KB | Output is correct |
30 | Correct | 3 ms | 4520 KB | Output is correct |
31 | Correct | 3 ms | 4520 KB | Output is correct |
32 | Correct | 3 ms | 4520 KB | Output is correct |
33 | Correct | 4 ms | 4520 KB | Output is correct |
34 | Correct | 4 ms | 4600 KB | Output is correct |
35 | Correct | 17 ms | 4868 KB | Output is correct |
36 | Correct | 4 ms | 4868 KB | Output is correct |
37 | Correct | 9 ms | 5128 KB | Output is correct |
38 | Correct | 13 ms | 5376 KB | Output is correct |
39 | Correct | 11 ms | 5680 KB | Output is correct |
40 | Correct | 12 ms | 5948 KB | Output is correct |
41 | Correct | 12 ms | 6280 KB | Output is correct |
42 | Correct | 64 ms | 6472 KB | Output is correct |
43 | Correct | 60 ms | 6692 KB | Output is correct |
44 | Correct | 73 ms | 6760 KB | Output is correct |
45 | Correct | 10 ms | 6968 KB | Output is correct |
46 | Correct | 10 ms | 7184 KB | Output is correct |
47 | Correct | 20 ms | 8156 KB | Output is correct |
48 | Correct | 9 ms | 8156 KB | Output is correct |
49 | Correct | 9 ms | 8156 KB | Output is correct |
50 | Correct | 7 ms | 8156 KB | Output is correct |
51 | Correct | 32 ms | 9036 KB | Output is correct |
52 | Correct | 31 ms | 9036 KB | Output is correct |
53 | Correct | 22 ms | 9036 KB | Output is correct |
54 | Correct | 4 ms | 9036 KB | Output is correct |
55 | Correct | 5 ms | 9036 KB | Output is correct |
56 | Correct | 824 ms | 9236 KB | Output is correct |
57 | Correct | 64 ms | 10024 KB | Output is correct |
58 | Correct | 870 ms | 10024 KB | Output is correct |
59 | Correct | 811 ms | 10024 KB | Output is correct |
60 | Correct | 854 ms | 10024 KB | Output is correct |
61 | Correct | 720 ms | 10024 KB | Output is correct |
62 | Correct | 13 ms | 10024 KB | Output is correct |
63 | Correct | 28 ms | 10024 KB | Output is correct |
64 | Correct | 30 ms | 10024 KB | Output is correct |
65 | Correct | 36 ms | 10024 KB | Output is correct |
66 | Correct | 48 ms | 10516 KB | Output is correct |
67 | Correct | 45 ms | 10684 KB | Output is correct |