Submission #976545

#TimeUsernameProblemLanguageResultExecution timeMemory
976545Elliot_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; } 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)

cyberland.cpp: In function 'bool dfs_hunt(long long int, long long int)':
cyberland.cpp:32:9: error: return-statement with no value, in function returning 'bool' [-fpermissive]
   32 |         return;
      |         ^~~~~~