Submission #976547

#TimeUsernameProblemLanguageResultExecution timeMemory
976547Elliot_7002Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define int long long #define INF 1e15 vector<vector<pair<int,int>>> adj; vector<double> distances; vector<bool> visited; priority_queue<int> q; void dijkstra(int source) { visited[source] = true; distances[source] = 0; q.push(source); while(!q.empty()){ int a = q.top(); q.pop(); if(visited[a]){ continue; } for(auto neigh: adj[a]){ if(distances[a] + neigh.second < distances[neigh.first]){ distances[neigh.first] = distances[a] + neigh.second; q.push(neigh.second); } } } } bool dfs_hunt(int node, int target){ bool found = false; if(visited[node]){ return found; } if(node == target){ found = true; return found; } for(auto i : adj[node]){ found = dfs_hunt(i.first,target); if(found){ return found; } } return found; } double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){ adj.clear(); adj.resize(n); visited.clear(); visited.resize(n,false); for(int i = 0; i < m ;i++){ adj[x[i]].push_back({y[i],c[i]}); adj[y[i]].push_back({x[i],c[i]}); } for(int i = 0; i < n; i++){ distances[i] = INF; } if(!dfs_hunt(0, h)){ return -1; } else{ visited.clear(); visited.resize(n,false); dijkstra(h); int mini = INF; for(int i = 0; i < n; i++){ if(arr[i] == 0){ if(distances[i] < mini){ mini = distances[i]; } } } return mini; } }

Compilation message (stderr)

/usr/bin/ld: /tmp/cc5GFKhp.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