제출 #1179208

#제출 시각아이디문제언어결과실행 시간메모리
1179208JelalTkm사이버랜드 (APIO23_cyberland)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "cyberland.h" #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; // #define int long long int // const int N = 2e5 + 10; // const int md = 1e9 + 7; // const int INF = 1e18; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> w, vector<int> a) { vector<vector<pair<int, int>>> g(n + 1, vector<pair<int, int>> ()); for (int i = 0; i < m; i++) { g[x[i]].push_back({y[i], w[i]}); g[y[i]].push_back({x[i], w[i]}); } vector<double> dist(g.size() + 10, 0); set<pair<double, int>> q; dist[h] = 0; q.insert({0, h}); double ans = 0; while (!q.empty()) { int v = (*q.begin()).second; if (!a[v]) { ans = dist[v]; break; } q.erase(q.begin()); if (!visited[v]) for (auto i : g[v]) { if (!dist[i.first]) dist[i.first] = dist[v] + i.second; else dist[i.first] = min(dist[i.first], dist[v] + (double)i.second); if (!visited[i.first]) q.insert({dist[i.first], i.first}); } visited[v] = 1; } if (ans != 0) return ans; else return dist[0]; } // int32_t main(int32_t argc, char *argv[]) { // ios::sync_with_stdio(false); // cin.tie(nullptr); // int T = 1; // // cin >> T; // while (T--) { // cout << solve(4, 4, 30, 3, {0, 0, 1, 2}, {1, 2, 3, 3}, {5, 4, 2, 4}, {1, 0, 1, 1}) << '\n'; // } // return 0; // }

컴파일 시 표준 에러 (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:34:10: error: 'visited' was not declared in this scope
   34 |     if (!visited[v])
      |          ^~~~~~~
cyberland.cpp:42:5: error: 'visited' was not declared in this scope
   42 |     visited[v] = 1;
      |     ^~~~~~~