Submission #1110087

# Submission time Handle Problem Language Result Execution time Memory
1110087 2024-11-08T17:05:11 Z simona1230 Jakarta Skyscrapers (APIO15_skyscraper) C++17
22 / 100
15 ms 9040 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];
int ver[30001][55];
int s=50,num;
void read()
{
    cin>>n>>m;
    num=n+m;
    for(int i=0; i<n; i++)
    {
        for(int j=1;j<=s;j++)
        {
            v[num].push_back({m+i,0});
            if(i>=j)
            {
                v[num].push_back({ver[i-j][j],1});
                v[ver[i-j][j]].push_back({num,1});
            }
            ver[i][j]=num++;
        }
    }

    for(int i=0; i<m; i++)
    {
        int x,y;
        cin>>x>>y;

        if(y>s)
        {
            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});
            }
        }
        else
        {
            v[i].push_back({ver[x][y],0});
        }

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

int d[7000000];
priority_queue<edge> q;
void dijkstra()
{
    for(int i=0; i<=num; 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:89:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |             for(int i=0; i<v[e.x].size(); i++)
      |                          ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3152 KB Output is correct
2 Correct 1 ms 3152 KB Output is correct
3 Correct 2 ms 3152 KB Output is correct
4 Correct 2 ms 3152 KB Output is correct
5 Correct 1 ms 3152 KB Output is correct
6 Correct 1 ms 3152 KB Output is correct
7 Correct 1 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3152 KB Output is correct
2 Correct 1 ms 3152 KB Output is correct
3 Correct 1 ms 3152 KB Output is correct
4 Correct 2 ms 3152 KB Output is correct
5 Correct 2 ms 3152 KB Output is correct
6 Correct 1 ms 3152 KB Output is correct
7 Correct 2 ms 3152 KB Output is correct
8 Correct 1 ms 3152 KB Output is correct
9 Correct 2 ms 3152 KB Output is correct
10 Correct 2 ms 3580 KB Output is correct
11 Correct 3 ms 3420 KB Output is correct
12 Correct 3 ms 3408 KB Output is correct
13 Correct 2 ms 3584 KB Output is correct
14 Correct 3 ms 3584 KB Output is correct
15 Correct 3 ms 3408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3152 KB Output is correct
2 Correct 2 ms 3152 KB Output is correct
3 Correct 2 ms 3152 KB Output is correct
4 Correct 1 ms 3152 KB Output is correct
5 Correct 2 ms 3152 KB Output is correct
6 Correct 1 ms 3152 KB Output is correct
7 Correct 1 ms 3200 KB Output is correct
8 Correct 2 ms 3152 KB Output is correct
9 Correct 2 ms 3152 KB Output is correct
10 Correct 2 ms 3408 KB Output is correct
11 Correct 3 ms 3408 KB Output is correct
12 Correct 2 ms 3408 KB Output is correct
13 Correct 2 ms 3576 KB Output is correct
14 Correct 3 ms 3408 KB Output is correct
15 Correct 3 ms 3408 KB Output is correct
16 Correct 3 ms 3664 KB Output is correct
17 Runtime error 15 ms 9040 KB Execution killed with signal 6
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3152 KB Output is correct
2 Correct 2 ms 3152 KB Output is correct
3 Correct 2 ms 3152 KB Output is correct
4 Correct 2 ms 3152 KB Output is correct
5 Correct 1 ms 3152 KB Output is correct
6 Correct 1 ms 3152 KB Output is correct
7 Correct 2 ms 3152 KB Output is correct
8 Correct 2 ms 3152 KB Output is correct
9 Correct 2 ms 3152 KB Output is correct
10 Correct 2 ms 3408 KB Output is correct
11 Correct 3 ms 3408 KB Output is correct
12 Correct 3 ms 3408 KB Output is correct
13 Correct 2 ms 3408 KB Output is correct
14 Correct 3 ms 3576 KB Output is correct
15 Correct 3 ms 3408 KB Output is correct
16 Correct 2 ms 3664 KB Output is correct
17 Runtime error 14 ms 9040 KB Execution killed with signal 6
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3152 KB Output is correct
2 Correct 1 ms 3152 KB Output is correct
3 Correct 1 ms 3152 KB Output is correct
4 Correct 1 ms 3152 KB Output is correct
5 Correct 1 ms 3152 KB Output is correct
6 Correct 1 ms 3152 KB Output is correct
7 Correct 1 ms 3152 KB Output is correct
8 Correct 1 ms 3152 KB Output is correct
9 Correct 2 ms 3152 KB Output is correct
10 Correct 2 ms 3408 KB Output is correct
11 Correct 2 ms 3408 KB Output is correct
12 Correct 2 ms 3408 KB Output is correct
13 Correct 2 ms 3408 KB Output is correct
14 Correct 3 ms 3408 KB Output is correct
15 Correct 3 ms 3408 KB Output is correct
16 Correct 4 ms 3664 KB Output is correct
17 Runtime error 13 ms 9040 KB Execution killed with signal 6
18 Halted 0 ms 0 KB -