Submission #1109595

# Submission time Handle Problem Language Result Execution time Memory
1109595 2024-11-07T06:46:11 Z simona1230 Jakarta Skyscrapers (APIO15_skyscraper) C++17
36 / 100
405 ms 262144 KB
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

struct edge
{
    int x,d;
    edge(){}
    edge(int _x,int _d)
    {
        x=_x;
        d=_d;
    }

    bool operator<(const edge&e)const
    {
        return e.d<d;
    }
};

int n,m;
vector<edge> v[32001];
void read()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        for(int j=x;j<n;j+=y)
        {
            //cout<<i<<" "<<j+m<<endl;
            v[i].push_back({j+m,(j-x)/y});
        }

        for(int j=x-y;j>=0;j-=y)
        {
            //cout<<i<<" "<<j+m<<endl;
            v[i].push_back({j+m,(x-j)/y});
        }

        //cout<<x+m<<" "<<i<<endl;
        v[x+m].push_back({i,0});
    }
}

int d[32001];
priority_queue<edge> q;
void dijkstra()
{
    for(int i=0;i<n+m;i++)
        d[i]=1e9;

    d[0]=0;
    q.push({0,0});
    while(q.size())
    {
        edge e=q.top();
        //cout<<e.x<<endl;
        q.pop();

        if(d[e.x]>=e.d)
        {
            for(int i=0;i<v[e.x].size();i++)
            {
                edge nb=v[e.x][i];
                if(nb.d+e.d<d[nb.x])
                {
                    d[nb.x]=nb.d+e.d;
                    q.push({nb.x,d[nb.x]});
                }
            }
        }
    }
}

int main()
{
    read();
    dijkstra();
    if(d[1]==1e9)d[1]=-1;
    cout<<d[1]<<endl;
    return 0;
}

Compilation message

skyscraper.cpp: In function 'void dijkstra()':
skyscraper.cpp:64:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |             for(int i=0;i<v[e.x].size();i++)
      |                         ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1104 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 2 ms 1104 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 2 ms 1104 KB Output is correct
6 Correct 2 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 1104 KB Output is correct
9 Correct 2 ms 1104 KB Output is correct
10 Correct 2 ms 1104 KB Output is correct
11 Correct 2 ms 1360 KB Output is correct
12 Correct 5 ms 3164 KB Output is correct
13 Correct 6 ms 3324 KB Output is correct
14 Correct 2 ms 1104 KB Output is correct
15 Correct 2 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1104 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 2 ms 1104 KB Output is correct
4 Correct 2 ms 1104 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 1104 KB Output is correct
9 Correct 2 ms 1104 KB Output is correct
10 Correct 1 ms 1104 KB Output is correct
11 Correct 2 ms 1360 KB Output is correct
12 Correct 5 ms 3152 KB Output is correct
13 Correct 5 ms 3064 KB Output is correct
14 Correct 3 ms 1104 KB Output is correct
15 Correct 2 ms 1228 KB Output is correct
16 Correct 2 ms 1104 KB Output is correct
17 Correct 3 ms 1360 KB Output is correct
18 Correct 2 ms 1208 KB Output is correct
19 Correct 2 ms 1104 KB Output is correct
20 Correct 57 ms 33224 KB Output is correct
21 Correct 2 ms 1104 KB Output is correct
22 Correct 1 ms 1104 KB Output is correct
23 Correct 2 ms 1104 KB Output is correct
24 Correct 2 ms 1360 KB Output is correct
25 Correct 3 ms 1304 KB Output is correct
26 Correct 60 ms 30244 KB Output is correct
27 Correct 53 ms 28488 KB Output is correct
28 Correct 3 ms 1360 KB Output is correct
29 Correct 3 ms 1872 KB Output is correct
30 Correct 2 ms 1360 KB Output is correct
31 Correct 2 ms 1616 KB Output is correct
32 Correct 2 ms 1360 KB Output is correct
33 Correct 5 ms 2640 KB Output is correct
34 Correct 5 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1104 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 1 ms 1272 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 1104 KB Output is correct
9 Correct 1 ms 1104 KB Output is correct
10 Correct 1 ms 1104 KB Output is correct
11 Correct 2 ms 1360 KB Output is correct
12 Correct 5 ms 3152 KB Output is correct
13 Correct 5 ms 3408 KB Output is correct
14 Correct 2 ms 1104 KB Output is correct
15 Correct 2 ms 1104 KB Output is correct
16 Correct 2 ms 1204 KB Output is correct
17 Correct 3 ms 1360 KB Output is correct
18 Correct 2 ms 1272 KB Output is correct
19 Correct 1 ms 1104 KB Output is correct
20 Correct 59 ms 33344 KB Output is correct
21 Correct 2 ms 1104 KB Output is correct
22 Correct 2 ms 1104 KB Output is correct
23 Correct 2 ms 1104 KB Output is correct
24 Correct 3 ms 1400 KB Output is correct
25 Correct 3 ms 1532 KB Output is correct
26 Correct 60 ms 30284 KB Output is correct
27 Correct 56 ms 28520 KB Output is correct
28 Correct 3 ms 1360 KB Output is correct
29 Correct 3 ms 1972 KB Output is correct
30 Correct 2 ms 1360 KB Output is correct
31 Correct 3 ms 1616 KB Output is correct
32 Correct 3 ms 1452 KB Output is correct
33 Correct 5 ms 2640 KB Output is correct
34 Correct 5 ms 2640 KB Output is correct
35 Correct 16 ms 3920 KB Output is correct
36 Correct 5 ms 1468 KB Output is correct
37 Correct 17 ms 4944 KB Output is correct
38 Correct 19 ms 5036 KB Output is correct
39 Correct 21 ms 5200 KB Output is correct
40 Correct 20 ms 4944 KB Output is correct
41 Correct 21 ms 4944 KB Output is correct
42 Runtime error 403 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1104 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 1 ms 1104 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 1 ms 1104 KB Output is correct
6 Correct 1 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 1 ms 1104 KB Output is correct
9 Correct 2 ms 1200 KB Output is correct
10 Correct 2 ms 1104 KB Output is correct
11 Correct 2 ms 1360 KB Output is correct
12 Correct 6 ms 3152 KB Output is correct
13 Correct 5 ms 3152 KB Output is correct
14 Correct 2 ms 1104 KB Output is correct
15 Correct 2 ms 1104 KB Output is correct
16 Correct 1 ms 1104 KB Output is correct
17 Correct 3 ms 1360 KB Output is correct
18 Correct 2 ms 1208 KB Output is correct
19 Correct 2 ms 1104 KB Output is correct
20 Correct 58 ms 33164 KB Output is correct
21 Correct 2 ms 1104 KB Output is correct
22 Correct 2 ms 1104 KB Output is correct
23 Correct 2 ms 1272 KB Output is correct
24 Correct 3 ms 1528 KB Output is correct
25 Correct 3 ms 1360 KB Output is correct
26 Correct 60 ms 30104 KB Output is correct
27 Correct 56 ms 28452 KB Output is correct
28 Correct 2 ms 1360 KB Output is correct
29 Correct 4 ms 1944 KB Output is correct
30 Correct 2 ms 1360 KB Output is correct
31 Correct 2 ms 1616 KB Output is correct
32 Correct 3 ms 1360 KB Output is correct
33 Correct 6 ms 2640 KB Output is correct
34 Correct 5 ms 2640 KB Output is correct
35 Correct 15 ms 3768 KB Output is correct
36 Correct 4 ms 1628 KB Output is correct
37 Correct 16 ms 4944 KB Output is correct
38 Correct 19 ms 5020 KB Output is correct
39 Correct 20 ms 5200 KB Output is correct
40 Correct 19 ms 4944 KB Output is correct
41 Correct 18 ms 5100 KB Output is correct
42 Runtime error 405 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -