제출 #759622

#제출 시각아이디문제언어결과실행 시간메모리
759622IvanJ사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include "cyberland.h" #include<bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 1e5 + 5; const double inf = 1e18; double dist[maxn], dist1[maxn]; vector<ii> adj[maxn]; int vis[maxn], change[maxn]; int X; void reach(int x) { if(vis[x] || x == X) return; vis[x] = 1; for(auto p : adj[x]) reach(p.x); } double solve(int N, int M, int K, int H, vector<int> u, vector<int> v, vector<int> c, vector<int> arr) { for(int i = 0;i < N;i++) { adj[i].clear(); vis[i] = 0; dist1[i] = inf; } for(int i = 0;i < M;i++) adj[u[i]].pb({v[i], c[i]}), adj[v[i]].pb({u[i], c[i]}); X = H; reach(0); for(int i = 0;i < N;i++) if(arr[i] == 0 && vis[i] == 1) dist1[i] = 0; dist1[0] = 0; for(int k = 0;k <= min(K, maxk);k++) { set<pair<double, int>> s; for(int i = 0;i < N;i++) { change[i] = 0; dist[i] = dist1[i]; if(vis[i] == 1) s.insert({dist[i], i}); } int flag = 0; while(s.size()) { auto state = *s.begin(); s.erase(state); int x = state.y; if(x == H) continue; for(auto p : adj[x]) { int y = p.x; double cost = p.y; if(dist[x] + cost == dist1[y] && arr[y] == 2) change[y] = 1, flag = 1; if(dist[x] + cost < dist1[y]) { s.erase({dist1[y], y}); dist1[y] = dist[x] + cost; change[y] = 1, flag = 1; s.insert({dist1[y], y}); } } } for(int i = 0;i < N;i++) if(arr[i] == 2 && change[i] == 1) dist1[i] /= 2.0; if(flag == 0) break; } if(dist[H] == inf) return -1; return dist[H]; }

컴파일 시 표준 에러 (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:44:28: error: 'maxk' was not declared in this scope; did you mean 'maxn'?
   44 |  for(int k = 0;k <= min(K, maxk);k++) {
      |                            ^~~~
      |                            maxn