Submission #724749

# Submission time Handle Problem Language Result Execution time Memory
724749 2023-04-15T21:03:29 Z tigar Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
918 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll b[30030], p[30030];
vector<int>srapers[30030];
vector<pair<int, int> >graff[30030];
ll dist[30030];
bool check1[30030];
ll INF=LONG_LONG_MAX;

void dijkstra(ll cvor)
{
    for(int i=0; i<30030; i++){check1[i]=false; dist[i]=INF;}
    priority_queue<pair<ll, ll> >ord;
    dist[cvor]=0;
    ord.push({0, cvor});
    while(!ord.empty())
    {
        int cv=ord.top().second;
        ord.pop();
        if(check1[cv])continue;
        check1[cv]=true;
        for(int j=0; j<graff[cv].size(); j++)
        {
            ll pp=graff[cv][j].first;
            dist[pp]=min(dist[pp], dist[cv]+graff[cv][j].second);
            if(!check1[pp])ord.push({-dist[pp], pp});
        }
    }
}

int main()
{
    ll m, n;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>b[i]>>p[i];
        srapers[b[i]].push_back(i);
    }
    for(int i=0; i<m; i++)
    {
        int br=0;
        bool ch=false;
        while(b[i]-br*p[i]>=0 or b[i]+br*p[i]<n)
        {
            int j;
            if(b[i]-br*p[i]>=0)
            {
                j=b[i]-br*p[i];
                for(int l=0; l<srapers[j].size(); l++)
                {
                    graff[i].push_back({srapers[j][l], br});
                }
            }
            if(b[i]+br*p[i]<n)
            {
                j=b[i]+br*p[i];
                for(int l=0; l<srapers[j].size(); l++)
                {
                    graff[i].push_back({srapers[j][l], br});
                }
            }
            br++;
        }
    }
    dijkstra(0);
    if(dist[1]==INF){cout<<-1; return 0;}
    cout<<dist[1];
    return 0;
}

Compilation message

skyscraper.cpp: In function 'void dijkstra(ll)':
skyscraper.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j=0; j<graff[cv].size(); j++)
      |                      ~^~~~~~~~~~~~~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:52:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                 for(int l=0; l<srapers[j].size(); l++)
      |                              ~^~~~~~~~~~~~~~~~~~
skyscraper.cpp:60:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |                 for(int l=0; l<srapers[j].size(); l++)
      |                              ~^~~~~~~~~~~~~~~~~~
skyscraper.cpp:45:14: warning: unused variable 'ch' [-Wunused-variable]
   45 |         bool ch=false;
      |              ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1980 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1976 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 2 ms 1972 KB Output is correct
10 Correct 3 ms 2132 KB Output is correct
11 Correct 24 ms 5820 KB Output is correct
12 Correct 873 ms 98776 KB Output is correct
13 Correct 841 ms 97500 KB Output is correct
14 Correct 21 ms 5456 KB Output is correct
15 Correct 21 ms 5460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1980 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1976 KB Output is correct
7 Correct 1 ms 1980 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 1 ms 2004 KB Output is correct
10 Correct 2 ms 2132 KB Output is correct
11 Correct 24 ms 5800 KB Output is correct
12 Correct 888 ms 98772 KB Output is correct
13 Correct 860 ms 97492 KB Output is correct
14 Correct 20 ms 5456 KB Output is correct
15 Correct 21 ms 5460 KB Output is correct
16 Correct 2 ms 2260 KB Output is correct
17 Correct 7 ms 3028 KB Output is correct
18 Correct 2 ms 2004 KB Output is correct
19 Correct 2 ms 2004 KB Output is correct
20 Correct 366 ms 50660 KB Output is correct
21 Correct 2 ms 2108 KB Output is correct
22 Correct 2 ms 2004 KB Output is correct
23 Correct 3 ms 2108 KB Output is correct
24 Correct 4 ms 2388 KB Output is correct
25 Correct 4 ms 2260 KB Output is correct
26 Correct 744 ms 93152 KB Output is correct
27 Correct 790 ms 94824 KB Output is correct
28 Correct 3 ms 2260 KB Output is correct
29 Correct 5 ms 2644 KB Output is correct
30 Correct 2 ms 2004 KB Output is correct
31 Correct 3 ms 2132 KB Output is correct
32 Correct 3 ms 2104 KB Output is correct
33 Correct 21 ms 5460 KB Output is correct
34 Correct 21 ms 5456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 2 ms 1876 KB Output is correct
5 Correct 2 ms 1976 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1976 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1976 KB Output is correct
10 Correct 2 ms 2104 KB Output is correct
11 Correct 24 ms 5820 KB Output is correct
12 Correct 918 ms 98784 KB Output is correct
13 Correct 872 ms 97552 KB Output is correct
14 Correct 20 ms 5440 KB Output is correct
15 Correct 20 ms 5500 KB Output is correct
16 Correct 2 ms 2260 KB Output is correct
17 Correct 8 ms 3136 KB Output is correct
18 Correct 2 ms 2004 KB Output is correct
19 Correct 2 ms 1980 KB Output is correct
20 Correct 374 ms 50640 KB Output is correct
21 Correct 2 ms 2132 KB Output is correct
22 Correct 2 ms 2004 KB Output is correct
23 Correct 2 ms 2108 KB Output is correct
24 Correct 4 ms 2388 KB Output is correct
25 Correct 4 ms 2260 KB Output is correct
26 Correct 755 ms 93148 KB Output is correct
27 Correct 794 ms 94776 KB Output is correct
28 Correct 3 ms 2388 KB Output is correct
29 Correct 5 ms 2644 KB Output is correct
30 Correct 2 ms 2004 KB Output is correct
31 Correct 3 ms 2132 KB Output is correct
32 Correct 2 ms 2104 KB Output is correct
33 Correct 23 ms 5460 KB Output is correct
34 Correct 20 ms 5456 KB Output is correct
35 Correct 428 ms 53884 KB Output is correct
36 Correct 14 ms 4084 KB Output is correct
37 Correct 426 ms 52384 KB Output is correct
38 Correct 603 ms 78884 KB Output is correct
39 Correct 622 ms 81424 KB Output is correct
40 Correct 600 ms 79588 KB Output is correct
41 Correct 539 ms 62072 KB Output is correct
42 Runtime error 459 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 2 ms 2132 KB Output is correct
11 Correct 23 ms 5816 KB Output is correct
12 Correct 888 ms 98752 KB Output is correct
13 Correct 861 ms 97508 KB Output is correct
14 Correct 20 ms 5456 KB Output is correct
15 Correct 20 ms 5460 KB Output is correct
16 Correct 2 ms 2236 KB Output is correct
17 Correct 7 ms 3028 KB Output is correct
18 Correct 2 ms 2112 KB Output is correct
19 Correct 1 ms 1976 KB Output is correct
20 Correct 370 ms 50740 KB Output is correct
21 Correct 2 ms 2132 KB Output is correct
22 Correct 2 ms 2004 KB Output is correct
23 Correct 2 ms 2132 KB Output is correct
24 Correct 4 ms 2388 KB Output is correct
25 Correct 3 ms 2260 KB Output is correct
26 Correct 745 ms 93120 KB Output is correct
27 Correct 790 ms 94828 KB Output is correct
28 Correct 3 ms 2312 KB Output is correct
29 Correct 4 ms 2644 KB Output is correct
30 Correct 2 ms 2004 KB Output is correct
31 Correct 3 ms 2228 KB Output is correct
32 Correct 2 ms 2132 KB Output is correct
33 Correct 20 ms 5460 KB Output is correct
34 Correct 20 ms 5436 KB Output is correct
35 Correct 419 ms 53840 KB Output is correct
36 Correct 15 ms 4212 KB Output is correct
37 Correct 438 ms 52432 KB Output is correct
38 Correct 593 ms 78896 KB Output is correct
39 Correct 626 ms 81252 KB Output is correct
40 Correct 687 ms 79624 KB Output is correct
41 Correct 571 ms 62012 KB Output is correct
42 Runtime error 476 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -