제출 #1153379

#제출 시각아이디문제언어결과실행 시간메모리
1153379TroySer사이버랜드 (APIO23_cyberland)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "cyberland.h" #include <vector> using namespace std; using ll = long long; vector<vector<ll> > adjList; map<pair<ll, ll>, double> weightMat; vector<bool> isReachable; double dijkstras(ll H, vector<int> &A) { ll N = adjList.size(); priority_queue<pair<double, ll>, vector<pair<double, ll> >, greater<pair<double, ll> > > pq; pq.push({0.0, H}); // check if H is actually reachable to 0 vector<double> distances(N, 1e16); vector<bool> visited(N, false); distances[H] = 0; while (!pq.empty()) { auto [currentDistance, currentNode] = pq.top(); pq.pop(); if (visited[currentNode]) continue; visited[currentNode] = true; for (ll v: adjList[currentNode]) { double newDist = currentDistance + weightMat[{currentNode, v}]; if (newDist < distances[v]) { distances[v] = newDist; pq.push({newDist, v}); } } } double minimumPossible = distances[0]; for (ll i = 0; i < A.size(); i++) { if ((A[i] == 0) && isReachable[i]) minimumPossible = min(minimumPossible, distances[i]); } return minimumPossible; } double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { adjList.clear(); weightMat.clear(); adjList.resize(N); for (ll i = 0; i < M; i++) { adjList[x[i]].push_back(y[i]); adjList[y[i]].push_back(x[i]); weightMat[{x[i], y[i]}] = (double)c[i]; weightMat[{y[i], x[i]}] = (double)c[i]; } isReachable.clear(); isReachable.resize(N, false); queue<ll> q; q.push(0); while (!q.empty()) { ll currentTop = q.front(); q.pop(); if (currentTop == H) break; isReachable[currentTop] = true; for (ll v: adjList[currentTop]) { if (!isReachable[v]) { isReachable[v] = true; q.push(v); } } } if (!isReachable[H]) { return -1; } double response = dijkstras(H, arr); if (response >= INF) { return -1.0; } else { return response; } }

컴파일 시 표준 에러 (stderr) 메시지

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:95:21: error: 'INF' was not declared in this scope
   95 |     if (response >= INF) {
      |                     ^~~
cyberland.cpp:101:1: warning: control reaches end of non-void function [-Wreturn-type]
  101 | }
      | ^