Submission #349923

# Submission time Handle Problem Language Result Execution time Memory
349923 2021-01-18T17:31:59 Z denkendoemeer Jakarta Skyscrapers (APIO15_skyscraper) C++14
100 / 100
341 ms 8672 KB
#include<bits/stdc++.h>
const int inf=1e9;
using namespace std;
int poz[30005],p[30005],dist[30005];
vector<pair<int,int>>g[30005];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
set<int>st[30005];
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&poz[i],&p[i]);
        st[poz[i]].insert(p[i]);
    }
    for(i=0;i<n;i++)
        dist[i]=inf;
    dist[poz[0]]=0;
    pq.push({0,poz[0]});
    while(pq.size()){
        int nod=pq.top().second;
        pq.pop();
        if (nod==poz[1]){
            printf("%d\n",dist[poz[1]]);
            return 0;
        }
        for(auto it:st[nod]){
            for(i=nod+it;i<n;i=i+it){
                if (dist[i]>dist[nod]+(i-nod)/it){
                    dist[i]=dist[nod]+(i-nod)/it;
                    pq.push({dist[i],i});
                }
                if (st[i].count(it))
                    break;
            }
            for(i=nod-it;i>=0;i=i-it){
                if (dist[i]>dist[nod]+(nod-i)/it){
                    dist[i]=dist[nod]+(nod-i)/it;
                    pq.push({dist[i],i});
                }
                if (st[i].count(it))
                    break;
            }
        }
    }
    printf("-1\n");
return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     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]
   15 |         scanf("%d%d",&poz[i],&p[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2432 KB Output is correct
2 Correct 2 ms 2412 KB Output is correct
3 Correct 2 ms 2424 KB Output is correct
4 Correct 2 ms 2412 KB Output is correct
5 Correct 2 ms 2412 KB Output is correct
6 Correct 2 ms 2412 KB Output is correct
7 Correct 2 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2412 KB Output is correct
2 Correct 2 ms 2412 KB Output is correct
3 Correct 2 ms 2412 KB Output is correct
4 Correct 2 ms 2412 KB Output is correct
5 Correct 2 ms 2412 KB Output is correct
6 Correct 2 ms 2412 KB Output is correct
7 Correct 2 ms 2412 KB Output is correct
8 Correct 2 ms 2412 KB Output is correct
9 Correct 2 ms 2412 KB Output is correct
10 Correct 2 ms 2412 KB Output is correct
11 Correct 3 ms 2540 KB Output is correct
12 Correct 2 ms 2412 KB Output is correct
13 Correct 2 ms 2412 KB Output is correct
14 Correct 3 ms 2540 KB Output is correct
15 Correct 3 ms 2540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2412 KB Output is correct
2 Correct 2 ms 2412 KB Output is correct
3 Correct 2 ms 2412 KB Output is correct
4 Correct 2 ms 2412 KB Output is correct
5 Correct 2 ms 2412 KB Output is correct
6 Correct 2 ms 2412 KB Output is correct
7 Correct 2 ms 2412 KB Output is correct
8 Correct 2 ms 2412 KB Output is correct
9 Correct 2 ms 2412 KB Output is correct
10 Correct 2 ms 2412 KB Output is correct
11 Correct 3 ms 2540 KB Output is correct
12 Correct 2 ms 2412 KB Output is correct
13 Correct 2 ms 2412 KB Output is correct
14 Correct 3 ms 2540 KB Output is correct
15 Correct 3 ms 2540 KB Output is correct
16 Correct 2 ms 2540 KB Output is correct
17 Correct 3 ms 2540 KB Output is correct
18 Correct 2 ms 2540 KB Output is correct
19 Correct 2 ms 2540 KB Output is correct
20 Correct 2 ms 2540 KB Output is correct
21 Correct 2 ms 2540 KB Output is correct
22 Correct 2 ms 2540 KB Output is correct
23 Correct 3 ms 2540 KB Output is correct
24 Correct 3 ms 2540 KB Output is correct
25 Correct 3 ms 2540 KB Output is correct
26 Correct 2 ms 2540 KB Output is correct
27 Correct 2 ms 2540 KB Output is correct
28 Correct 4 ms 2548 KB Output is correct
29 Correct 5 ms 2668 KB Output is correct
30 Correct 3 ms 2540 KB Output is correct
31 Correct 3 ms 2540 KB Output is correct
32 Correct 3 ms 2540 KB Output is correct
33 Correct 8 ms 2924 KB Output is correct
34 Correct 6 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2412 KB Output is correct
2 Correct 2 ms 2412 KB Output is correct
3 Correct 2 ms 2412 KB Output is correct
4 Correct 2 ms 2412 KB Output is correct
5 Correct 2 ms 2412 KB Output is correct
6 Correct 2 ms 2556 KB Output is correct
7 Correct 2 ms 2412 KB Output is correct
8 Correct 2 ms 2412 KB Output is correct
9 Correct 2 ms 2412 KB Output is correct
10 Correct 2 ms 2412 KB Output is correct
11 Correct 3 ms 2540 KB Output is correct
12 Correct 2 ms 2412 KB Output is correct
13 Correct 2 ms 2412 KB Output is correct
14 Correct 3 ms 2540 KB Output is correct
15 Correct 3 ms 2540 KB Output is correct
16 Correct 2 ms 2540 KB Output is correct
17 Correct 3 ms 2540 KB Output is correct
18 Correct 2 ms 2540 KB Output is correct
19 Correct 2 ms 2540 KB Output is correct
20 Correct 3 ms 2540 KB Output is correct
21 Correct 2 ms 2540 KB Output is correct
22 Correct 2 ms 2540 KB Output is correct
23 Correct 3 ms 2540 KB Output is correct
24 Correct 3 ms 2540 KB Output is correct
25 Correct 3 ms 2540 KB Output is correct
26 Correct 2 ms 2540 KB Output is correct
27 Correct 3 ms 2560 KB Output is correct
28 Correct 3 ms 2540 KB Output is correct
29 Correct 5 ms 2668 KB Output is correct
30 Correct 3 ms 2540 KB Output is correct
31 Correct 3 ms 2540 KB Output is correct
32 Correct 3 ms 2540 KB Output is correct
33 Correct 8 ms 2924 KB Output is correct
34 Correct 7 ms 2924 KB Output is correct
35 Correct 18 ms 4076 KB Output is correct
36 Correct 4 ms 2796 KB Output is correct
37 Correct 16 ms 3820 KB Output is correct
38 Correct 17 ms 4460 KB Output is correct
39 Correct 14 ms 4332 KB Output is correct
40 Correct 15 ms 4332 KB Output is correct
41 Correct 16 ms 4460 KB Output is correct
42 Correct 8 ms 2924 KB Output is correct
43 Correct 8 ms 2924 KB Output is correct
44 Correct 8 ms 2924 KB Output is correct
45 Correct 37 ms 4716 KB Output is correct
46 Correct 28 ms 4716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2412 KB Output is correct
2 Correct 2 ms 2412 KB Output is correct
3 Correct 2 ms 2412 KB Output is correct
4 Correct 2 ms 2412 KB Output is correct
5 Correct 2 ms 2412 KB Output is correct
6 Correct 2 ms 2412 KB Output is correct
7 Correct 2 ms 2412 KB Output is correct
8 Correct 2 ms 2412 KB Output is correct
9 Correct 2 ms 2412 KB Output is correct
10 Correct 2 ms 2412 KB Output is correct
11 Correct 3 ms 2540 KB Output is correct
12 Correct 2 ms 2412 KB Output is correct
13 Correct 2 ms 2412 KB Output is correct
14 Correct 3 ms 2540 KB Output is correct
15 Correct 3 ms 2540 KB Output is correct
16 Correct 2 ms 2540 KB Output is correct
17 Correct 3 ms 2540 KB Output is correct
18 Correct 2 ms 2540 KB Output is correct
19 Correct 3 ms 2540 KB Output is correct
20 Correct 3 ms 2540 KB Output is correct
21 Correct 2 ms 2540 KB Output is correct
22 Correct 2 ms 2540 KB Output is correct
23 Correct 3 ms 2540 KB Output is correct
24 Correct 3 ms 2540 KB Output is correct
25 Correct 3 ms 2540 KB Output is correct
26 Correct 2 ms 2540 KB Output is correct
27 Correct 2 ms 2540 KB Output is correct
28 Correct 3 ms 2540 KB Output is correct
29 Correct 5 ms 2668 KB Output is correct
30 Correct 3 ms 2540 KB Output is correct
31 Correct 3 ms 2540 KB Output is correct
32 Correct 3 ms 2540 KB Output is correct
33 Correct 10 ms 3180 KB Output is correct
34 Correct 7 ms 2924 KB Output is correct
35 Correct 17 ms 4076 KB Output is correct
36 Correct 4 ms 2796 KB Output is correct
37 Correct 14 ms 3820 KB Output is correct
38 Correct 17 ms 4460 KB Output is correct
39 Correct 14 ms 4332 KB Output is correct
40 Correct 14 ms 4332 KB Output is correct
41 Correct 16 ms 4460 KB Output is correct
42 Correct 8 ms 2924 KB Output is correct
43 Correct 8 ms 2924 KB Output is correct
44 Correct 8 ms 2924 KB Output is correct
45 Correct 35 ms 4716 KB Output is correct
46 Correct 27 ms 4716 KB Output is correct
47 Correct 20 ms 4716 KB Output is correct
48 Correct 10 ms 3948 KB Output is correct
49 Correct 9 ms 3948 KB Output is correct
50 Correct 7 ms 3564 KB Output is correct
51 Correct 28 ms 5228 KB Output is correct
52 Correct 24 ms 5236 KB Output is correct
53 Correct 14 ms 4844 KB Output is correct
54 Correct 3 ms 2796 KB Output is correct
55 Correct 4 ms 2796 KB Output is correct
56 Correct 12 ms 4460 KB Output is correct
57 Correct 3 ms 3052 KB Output is correct
58 Correct 10 ms 3180 KB Output is correct
59 Correct 11 ms 3308 KB Output is correct
60 Correct 10 ms 3308 KB Output is correct
61 Correct 12 ms 3436 KB Output is correct
62 Correct 17 ms 4588 KB Output is correct
63 Correct 64 ms 6628 KB Output is correct
64 Correct 71 ms 6628 KB Output is correct
65 Correct 94 ms 6628 KB Output is correct
66 Correct 341 ms 8672 KB Output is correct
67 Correct 295 ms 8672 KB Output is correct