Submission #155397

# Submission time Handle Problem Language Result Execution time Memory
155397 2019-09-28T00:53:02 Z dantoh000 Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
217 ms 26360 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int dist[30005];
vector<int> a[30005];
int h[30005][205];
int n,m;
int k = 200;
int s;
int e;
int main(){
    scanf("%d%d",&n,&m);
    for (int i = 0; i < m; i++){
        int b,p;
        scanf("%d%d",&b,&p);
        if (i == 0) s = b;
        if (i == 1) e = b;
        if (p > k || !h[b][p]){
            a[b].push_back(p);
        }
        if (p <= k) h[b][p] = 1;
    }
    priority_queue<ii,vector<ii>,greater<ii> > pq;
    memset(dist,-1,sizeof(dist));
    dist[s] = 0;
    pq.push(ii(0,s));
    while (pq.size()){
        ii cur = pq.top(); pq.pop();
        int d = cur.first, u = cur.second;
        if (u == e) break;
        if (dist[u] > d) continue;
        for (auto x : a[u]){
            for (int v = u-x; v >= 0; v-=x){
                if (dist[v] == -1 || dist[v] > dist[u]+(u-v)/x){
                    dist[v] = dist[u]+(u-v)/x;
                    pq.push(ii(dist[v],v));
                }
                if (h[v][x]) break;
            }
            for (int v = u+x; v < n; v+=x){
                if (dist[v] == -1 || dist[v] > dist[u]+(v-u)/x){
                    dist[v] = dist[u]+(v-u)/x;
                    pq.push(ii(dist[v],v));
                }
                if (h[v][x]) break;
            }
        }
    }
    printf("%d",dist[e]);
    return 0;


}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&b,&p);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1148 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1080 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1272 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1204 KB Output is correct
11 Correct 4 ms 1272 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1272 KB Output is correct
14 Correct 3 ms 1272 KB Output is correct
15 Correct 3 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1272 KB Output is correct
10 Correct 4 ms 1276 KB Output is correct
11 Correct 3 ms 1272 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1272 KB Output is correct
14 Correct 3 ms 1272 KB Output is correct
15 Correct 3 ms 1272 KB Output is correct
16 Correct 3 ms 1272 KB Output is correct
17 Correct 5 ms 1784 KB Output is correct
18 Correct 4 ms 1528 KB Output is correct
19 Correct 4 ms 1272 KB Output is correct
20 Correct 6 ms 2936 KB Output is correct
21 Correct 3 ms 1400 KB Output is correct
22 Correct 4 ms 1400 KB Output is correct
23 Correct 4 ms 1528 KB Output is correct
24 Correct 5 ms 1912 KB Output is correct
25 Correct 4 ms 1272 KB Output is correct
26 Correct 4 ms 1400 KB Output is correct
27 Correct 5 ms 1272 KB Output is correct
28 Correct 4 ms 1528 KB Output is correct
29 Correct 6 ms 1400 KB Output is correct
30 Correct 4 ms 1272 KB Output is correct
31 Correct 5 ms 1272 KB Output is correct
32 Correct 4 ms 1272 KB Output is correct
33 Correct 8 ms 1604 KB Output is correct
34 Correct 7 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1144 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1272 KB Output is correct
10 Correct 3 ms 1272 KB Output is correct
11 Correct 3 ms 1272 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1272 KB Output is correct
14 Correct 3 ms 1272 KB Output is correct
15 Correct 3 ms 1272 KB Output is correct
16 Correct 3 ms 1272 KB Output is correct
17 Correct 4 ms 1784 KB Output is correct
18 Correct 4 ms 1528 KB Output is correct
19 Correct 3 ms 1400 KB Output is correct
20 Correct 5 ms 2808 KB Output is correct
21 Correct 3 ms 1400 KB Output is correct
22 Correct 3 ms 1400 KB Output is correct
23 Correct 5 ms 1500 KB Output is correct
24 Correct 6 ms 1784 KB Output is correct
25 Correct 5 ms 1272 KB Output is correct
26 Correct 4 ms 1472 KB Output is correct
27 Correct 4 ms 1272 KB Output is correct
28 Correct 4 ms 1528 KB Output is correct
29 Correct 6 ms 1400 KB Output is correct
30 Correct 4 ms 1272 KB Output is correct
31 Correct 4 ms 1272 KB Output is correct
32 Correct 4 ms 1328 KB Output is correct
33 Correct 7 ms 1400 KB Output is correct
34 Correct 7 ms 1528 KB Output is correct
35 Correct 12 ms 2808 KB Output is correct
36 Correct 5 ms 2040 KB Output is correct
37 Correct 11 ms 3192 KB Output is correct
38 Correct 15 ms 3320 KB Output is correct
39 Correct 13 ms 3196 KB Output is correct
40 Correct 14 ms 3292 KB Output is correct
41 Correct 32 ms 3320 KB Output is correct
42 Correct 9 ms 1656 KB Output is correct
43 Correct 9 ms 1568 KB Output is correct
44 Correct 10 ms 2984 KB Output is correct
45 Correct 20 ms 1912 KB Output is correct
46 Correct 16 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 3 ms 1188 KB Output is correct
6 Correct 3 ms 1144 KB Output is correct
7 Correct 3 ms 1144 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 3 ms 1144 KB Output is correct
10 Correct 3 ms 1272 KB Output is correct
11 Correct 3 ms 1272 KB Output is correct
12 Correct 3 ms 1144 KB Output is correct
13 Correct 3 ms 1272 KB Output is correct
14 Correct 3 ms 1272 KB Output is correct
15 Correct 4 ms 1272 KB Output is correct
16 Correct 3 ms 1400 KB Output is correct
17 Correct 4 ms 1784 KB Output is correct
18 Correct 3 ms 1528 KB Output is correct
19 Correct 3 ms 1400 KB Output is correct
20 Correct 5 ms 2808 KB Output is correct
21 Correct 3 ms 1400 KB Output is correct
22 Correct 3 ms 1404 KB Output is correct
23 Correct 4 ms 1528 KB Output is correct
24 Correct 5 ms 1912 KB Output is correct
25 Correct 4 ms 1272 KB Output is correct
26 Correct 4 ms 1528 KB Output is correct
27 Correct 4 ms 1272 KB Output is correct
28 Correct 4 ms 1532 KB Output is correct
29 Correct 6 ms 1400 KB Output is correct
30 Correct 4 ms 1320 KB Output is correct
31 Correct 6 ms 1272 KB Output is correct
32 Correct 4 ms 1272 KB Output is correct
33 Correct 8 ms 1528 KB Output is correct
34 Correct 7 ms 1400 KB Output is correct
35 Correct 13 ms 2796 KB Output is correct
36 Correct 5 ms 2040 KB Output is correct
37 Correct 12 ms 3168 KB Output is correct
38 Correct 14 ms 3324 KB Output is correct
39 Correct 13 ms 3192 KB Output is correct
40 Correct 14 ms 3324 KB Output is correct
41 Correct 14 ms 3320 KB Output is correct
42 Correct 9 ms 1656 KB Output is correct
43 Correct 9 ms 1528 KB Output is correct
44 Correct 10 ms 3064 KB Output is correct
45 Correct 20 ms 1876 KB Output is correct
46 Correct 16 ms 1912 KB Output is correct
47 Correct 26 ms 7800 KB Output is correct
48 Correct 12 ms 2552 KB Output is correct
49 Correct 11 ms 2424 KB Output is correct
50 Correct 9 ms 2168 KB Output is correct
51 Correct 33 ms 3448 KB Output is correct
52 Correct 37 ms 3704 KB Output is correct
53 Correct 26 ms 2308 KB Output is correct
54 Correct 12 ms 1336 KB Output is correct
55 Correct 13 ms 1528 KB Output is correct
56 Correct 45 ms 26360 KB Output is correct
57 Correct 21 ms 9464 KB Output is correct
58 Correct 18 ms 1660 KB Output is correct
59 Correct 18 ms 1784 KB Output is correct
60 Correct 19 ms 2168 KB Output is correct
61 Correct 19 ms 1912 KB Output is correct
62 Correct 26 ms 2808 KB Output is correct
63 Correct 71 ms 2932 KB Output is correct
64 Correct 72 ms 2932 KB Output is correct
65 Correct 103 ms 3944 KB Output is correct
66 Correct 217 ms 3948 KB Output is correct
67 Correct 214 ms 3944 KB Output is correct