Submission #396690

# Submission time Handle Problem Language Result Execution time Memory
396690 2021-04-30T15:32:19 Z leinad2 Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 77132 KB
#include<bits/stdc++.h>
using namespace std;
int n, m, i, j, k, A[30010], a, b, w, s, e, B[30010][2];
vector<pair<int, int> >adj[30010];
map<int, int>mp[30010];
map<int, int>::iterator it;
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >pq;
main()
{
    ios_base::sync_with_stdio(!cin.tie(NULL));
    for(cin>>n>>m;i++<m;)
    {
        cin>>B[i][0]>>B[i][1];
        mp[B[i][1]][B[i][0]]++;
    }
    for(i=0;i++<30000;)
    {
        for(it=mp[i].begin();it!=mp[i].end();it++)
        {
            j=it->first;
            a=1;
            for(k=j+i;k<n;k+=i,a++)
            {
                adj[j].push_back({k, a});
                if(mp[i].find(k)!=mp[i].end())break;
            }
            a=1;
            for(k=j-i;k>=0;k-=i,a++)
            {
                adj[j].push_back({k, a});
                if(mp[i].find(k)!=mp[i].end())break;
            }
        }
    }
    s=B[1][0];e=B[2][0];
    for(i=0;i<n;i++)A[i]=1e9;
    pq.push({0, s});
    while(pq.size())
    {
        pair<int, int>p=pq.top();pq.pop();
        a=p.second;b=p.first;
        if(A[a]<1e9)continue;
        A[a]=b;
        for(i=0;i<adj[a].size();i++)
        {
            pq.push({A[a]+adj[a][i].second, adj[a][i].first});
        }
    }
    if(A[e]==1e9)A[e]=-1;cout<<A[e];
}

Compilation message

skyscraper.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      |      ^
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for(i=0;i<adj[a].size();i++)
      |                 ~^~~~~~~~~~~~~~
skyscraper.cpp:49:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   49 |     if(A[e]==1e9)A[e]=-1;cout<<A[e];
      |     ^~
skyscraper.cpp:49:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   49 |     if(A[e]==1e9)A[e]=-1;cout<<A[e];
      |                          ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2380 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 2 ms 2380 KB Output is correct
4 Correct 2 ms 2380 KB Output is correct
5 Correct 2 ms 2380 KB Output is correct
6 Correct 2 ms 2380 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2364 KB Output is correct
2 Correct 2 ms 2380 KB Output is correct
3 Correct 2 ms 2380 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 2 ms 2380 KB Output is correct
6 Correct 2 ms 2380 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
8 Correct 2 ms 2380 KB Output is correct
9 Correct 2 ms 2380 KB Output is correct
10 Correct 2 ms 2380 KB Output is correct
11 Correct 3 ms 2636 KB Output is correct
12 Correct 2 ms 2380 KB Output is correct
13 Correct 2 ms 2380 KB Output is correct
14 Correct 4 ms 2636 KB Output is correct
15 Correct 4 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2380 KB Output is correct
2 Correct 2 ms 2380 KB Output is correct
3 Correct 2 ms 2380 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 2 ms 2380 KB Output is correct
6 Correct 2 ms 2380 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
8 Correct 2 ms 2380 KB Output is correct
9 Correct 2 ms 2380 KB Output is correct
10 Correct 2 ms 2380 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 2 ms 2380 KB Output is correct
13 Correct 2 ms 2380 KB Output is correct
14 Correct 3 ms 2636 KB Output is correct
15 Correct 3 ms 2636 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 5 ms 2892 KB Output is correct
18 Correct 2 ms 2508 KB Output is correct
19 Correct 2 ms 2508 KB Output is correct
20 Correct 4 ms 2508 KB Output is correct
21 Correct 2 ms 2508 KB Output is correct
22 Correct 2 ms 2508 KB Output is correct
23 Correct 3 ms 2508 KB Output is correct
24 Correct 4 ms 2764 KB Output is correct
25 Correct 4 ms 2636 KB Output is correct
26 Correct 3 ms 2636 KB Output is correct
27 Correct 3 ms 2508 KB Output is correct
28 Correct 5 ms 2764 KB Output is correct
29 Correct 14 ms 3764 KB Output is correct
30 Correct 5 ms 2916 KB Output is correct
31 Correct 8 ms 3148 KB Output is correct
32 Correct 6 ms 2864 KB Output is correct
33 Correct 26 ms 4772 KB Output is correct
34 Correct 26 ms 4800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2380 KB Output is correct
3 Correct 2 ms 2380 KB Output is correct
4 Correct 2 ms 2380 KB Output is correct
5 Correct 2 ms 2380 KB Output is correct
6 Correct 2 ms 2380 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
8 Correct 2 ms 2380 KB Output is correct
9 Correct 2 ms 2380 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 3 ms 2636 KB Output is correct
12 Correct 2 ms 2380 KB Output is correct
13 Correct 2 ms 2380 KB Output is correct
14 Correct 3 ms 2636 KB Output is correct
15 Correct 3 ms 2640 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 5 ms 2892 KB Output is correct
18 Correct 2 ms 2508 KB Output is correct
19 Correct 3 ms 2508 KB Output is correct
20 Correct 3 ms 2508 KB Output is correct
21 Correct 2 ms 2508 KB Output is correct
22 Correct 2 ms 2508 KB Output is correct
23 Correct 3 ms 2508 KB Output is correct
24 Correct 4 ms 2764 KB Output is correct
25 Correct 4 ms 2708 KB Output is correct
26 Correct 3 ms 2508 KB Output is correct
27 Correct 4 ms 2508 KB Output is correct
28 Correct 5 ms 2764 KB Output is correct
29 Correct 14 ms 3784 KB Output is correct
30 Correct 5 ms 2892 KB Output is correct
31 Correct 8 ms 3152 KB Output is correct
32 Correct 6 ms 2892 KB Output is correct
33 Correct 26 ms 4824 KB Output is correct
34 Correct 26 ms 4820 KB Output is correct
35 Correct 33 ms 6340 KB Output is correct
36 Correct 6 ms 3124 KB Output is correct
37 Correct 48 ms 7788 KB Output is correct
38 Correct 48 ms 8204 KB Output is correct
39 Correct 49 ms 7364 KB Output is correct
40 Correct 48 ms 7108 KB Output is correct
41 Correct 48 ms 7236 KB Output is correct
42 Correct 8 ms 2940 KB Output is correct
43 Correct 7 ms 3020 KB Output is correct
44 Correct 8 ms 2964 KB Output is correct
45 Correct 112 ms 12792 KB Output is correct
46 Correct 114 ms 12744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2380 KB Output is correct
3 Correct 2 ms 2380 KB Output is correct
4 Correct 2 ms 2380 KB Output is correct
5 Correct 2 ms 2380 KB Output is correct
6 Correct 2 ms 2380 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
8 Correct 2 ms 2380 KB Output is correct
9 Correct 2 ms 2380 KB Output is correct
10 Correct 3 ms 2380 KB Output is correct
11 Correct 3 ms 2636 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 2 ms 2380 KB Output is correct
14 Correct 3 ms 2636 KB Output is correct
15 Correct 3 ms 2636 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 6 ms 2864 KB Output is correct
18 Correct 3 ms 2508 KB Output is correct
19 Correct 2 ms 2508 KB Output is correct
20 Correct 3 ms 2508 KB Output is correct
21 Correct 2 ms 2508 KB Output is correct
22 Correct 2 ms 2508 KB Output is correct
23 Correct 3 ms 2508 KB Output is correct
24 Correct 5 ms 2764 KB Output is correct
25 Correct 4 ms 2636 KB Output is correct
26 Correct 4 ms 2600 KB Output is correct
27 Correct 3 ms 2508 KB Output is correct
28 Correct 5 ms 2764 KB Output is correct
29 Correct 14 ms 3656 KB Output is correct
30 Correct 6 ms 2840 KB Output is correct
31 Correct 8 ms 3152 KB Output is correct
32 Correct 6 ms 2892 KB Output is correct
33 Correct 26 ms 4824 KB Output is correct
34 Correct 26 ms 4764 KB Output is correct
35 Correct 32 ms 6212 KB Output is correct
36 Correct 7 ms 3020 KB Output is correct
37 Correct 50 ms 7884 KB Output is correct
38 Correct 48 ms 8268 KB Output is correct
39 Correct 47 ms 7228 KB Output is correct
40 Correct 48 ms 7112 KB Output is correct
41 Correct 47 ms 7204 KB Output is correct
42 Correct 8 ms 3020 KB Output is correct
43 Correct 7 ms 3020 KB Output is correct
44 Correct 9 ms 3020 KB Output is correct
45 Correct 112 ms 12824 KB Output is correct
46 Correct 115 ms 12848 KB Output is correct
47 Correct 203 ms 20908 KB Output is correct
48 Correct 17 ms 6344 KB Output is correct
49 Correct 14 ms 5324 KB Output is correct
50 Correct 11 ms 4972 KB Output is correct
51 Correct 83 ms 9856 KB Output is correct
52 Correct 93 ms 10432 KB Output is correct
53 Correct 27 ms 5924 KB Output is correct
54 Correct 4 ms 3020 KB Output is correct
55 Correct 6 ms 3404 KB Output is correct
56 Correct 24 ms 5288 KB Output is correct
57 Correct 170 ms 13172 KB Output is correct
58 Correct 18 ms 4500 KB Output is correct
59 Correct 22 ms 4688 KB Output is correct
60 Correct 32 ms 5324 KB Output is correct
61 Correct 20 ms 4748 KB Output is correct
62 Correct 58 ms 10148 KB Output is correct
63 Correct 550 ms 34092 KB Output is correct
64 Correct 680 ms 42736 KB Output is correct
65 Execution timed out 1077 ms 77132 KB Time limit exceeded
66 Halted 0 ms 0 KB -