Submission #967052

#TimeUsernameProblemLanguageResultExecution timeMemory
967052dubabubaCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "cyberland.h" using namespace std; #define int long long typedef double dbl; typedef long long i64; typedef vector<int> vi; typedef pair<int, int> pii; #define ff first #define ss second #define MP make_pair const int mxk = 32; const int mxn = 1e5 + 10; vector<pii> adj[mxn]; dbl dis[mxk][mxn]; bool in[mxn]; template<typename T> void ono_min(T &MIN, T CMP) { if(MIN > CMP) MIN = CMP; } template<typename T> void ono_max(T &MAX, T CMP) { if(MAX < CMP) MAX = CMP; } dbl solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) { for(int i = 0; i < N; i++) { in[i] = 0; adj[i].clear(); } for(int i = 0; i < M; i++) { adj[x[i]].push_back(MP(y[i], c[i])); adj[y[i]].push_back(MP(x[i], c[i])); } priority_queue<pair<dbl, int>> pq[mxk]; queue<int> q; in[0] = 1; q.push(0); for(int i = 0; i < mxk; i++) for(int j = 0; j < N; j++) dis[i][j] = 1e18; pq[0].push(MP(0.0, 0)); dis[0][0] = 0.0; while(q.size()) { int u = q.front(); q.pop(); if(arr[u] == 0) { pq[0].push(MP(0.0, u)); dis[0][u] = 0.0; } for(pii p : adj[u]) { int v = p.ff; if(!in[v]) { in[v] = 1; q.push(v); } } } dbl ans = 1e18; for(int i = 0; i < mxk && i <= K; i++) { bool vis[N]; memset(vis, 0, sizeof vis); // cout << "k = " << i << endl; while(pq[i].size()) { dbl d = -pq[i].top().ff; int u = pq[i].top().ss; pq[i].pop(); if(vis[u]) continue; vis[u] = 1; // cout << u << ' ' << dis[i][u] << endl; if(u == H) continue; for(pii p : adj[u]) { int v = p.ff; int c = p.ss; if(v == 0 || arr[v] == 0) continue; // cout << u << " -> " << v << endl; if(!vis[v]) { pq[i].push(MP(-(d + c), v)); ono_min(dis[i][v], dis[i][u] + c); } if(arr[v] == 2) { pq[i].push(MP(-(d + c) / 2.0, v)); ono_min(dis[i + 1][v], (dis[i][u] + c) / 2.0); } } } // cout << dis[i][H] << endl; ono_min(ans, dis[i][H]); } return (ans < 1e18 ? ans : -1.0); }

Compilation message (stderr)

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