Submission #876690

#TimeUsernameProblemLanguageResultExecution timeMemory
876690vjudge1Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> // #include "cyberland.h" using namespace std; typedef long long ll; const int N = 2e5 + 1; vector<pair<int, int>> g[N]; double d[N][31]; double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { for (int i = 0; i < n; i++) { for(int j = 0;j <= k;j++){ d[i][j] = 1e15; } g[i].clear(); } for (int i = 0; i < m; i++) { g[x[i]].push_back({y[i], c[i]}); g[y[i]].push_back({x[i], c[i]}); } queue<int> q; vector<int> can(n,0); can[0] = 1; q.push(0); while(!q.empty()){ int v = q.front(); q.pop(); for(auto [to,w]:g[v]){ if(to == h || can[to]) continue; q.push(to); can[to] = 1; } } vector<int> vv(1, 0); set<pair<double,pair<int,int>>> st; for (int j = 0; j < n; j++) { if (!arr[j] && can[j]) { st.insert({0,{0,j}}); d[j][0] = 0; vv.push_back(j); } } while(!st.empty()){ auto [col,v] = (*st.begin()).second; st.erase({d[v][col],{col,v}}); // cout << v << ' ' << col << ' ' << d[v][col] << '\n'; for(auto [to,w]:g[v]){ if(col + 1 <= k && d[to][col + 1] > (d[v][col] + w) / 2 && arr[to] == 2){ st.erase({d[to][col + 1],{col + 1,to}}); d[to][col + 1] = (d[v][col] + w) / 2; st.insert({d[to][col + 1],{col + 1,to}}); } if(d[to][col] > d[v][col] + w){ st.erase({d[to][col],{col,to}}); d[to][col] = d[v][col] + w; st.insert({d[to][col],{col,to}}); } } } double res = 1e15; for(int i = 0;i <= 30;i++){ res = min(res,d[h][i]); } if(res == 1e15) res = -1; return res; } int main() { int T; assert(1 == scanf("%d", &T)); while (T--){ int N,M,K,H; assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H)); std::vector<int> x(M); std::vector<int> y(M); std::vector<int> c(M); std::vector<int> arr(N); for (int i=0;i<N;i++) assert(1 == scanf("%d", &arr[i])); for (int i=0;i<M;i++) assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i])); printf("%.12lf\n", solve(N, M, K, H, x, y, c, arr)); } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccAMc2Uh.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPVMWBg.o:cyberland.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status