Submission #1059098

# Submission time Handle Problem Language Result Execution time Memory
1059098 2024-08-14T17:12:26 Z vjudge1 Cyberland (APIO23_cyberland) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

long long dist[100001];

void dijkstra(vector<pair<long long,long long>> adj[],long long i)
{
    priority_queue<pair<long long,long long>> pq;
    pq.push({-0,i});
    dist[i]=0;
    while(pq.size()>0)
    {

        long long a=-pq.top().first,b=pq.top().second;
        pq.pop();
        for(auto it : adj[b])
        {
            if(dist[it.first]==-1 || (dist[it.first]>dist[b]+it.second))
            {
                dist[it.first]=dist[b]+it.second;
                pq.push({-dist[it.first],it.first});
            }
        }
    }

}

long long solve(long long N, long long M, long long K, long long H, std::vector<long long> x, std::vector<long long>
y, std::vector<long long> c, std::vector<long long> arr)
{
    memset(dist,-1,sizeof(dist));
    vector<pair<long long,long long>> adj[N+1];
    for(long long i=0;i<x.size();i++)
    {
        long long a=x[i],b=y[i],cc=c[i];
        adj[a].push_back({b,cc});
        adj[b].push_back({a,cc});
    }
    dijkstra(adj,0);
    return dist[H];

}

Compilation message

cyberland.cpp: In function 'void dijkstra(std::vector<std::pair<long long int, long long int> >*, long long int)':
cyberland.cpp:15:19: warning: unused variable 'a' [-Wunused-variable]
   15 |         long long a=-pq.top().first,b=pq.top().second;
      |                   ^
cyberland.cpp: In function 'long long int solve(long long int, long long int, long long int, long long int, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
cyberland.cpp:34:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(long long i=0;i<x.size();i++)
      |                       ~^~~~~~~~~
/usr/bin/ld: /tmp/ccd8Bezw.o: in function `main':
grader.cpp:(.text.startup+0x696): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status