Submission #884535

#TimeUsernameProblemLanguageResultExecution timeMemory
884535Trisanu_Das사이버랜드 (APIO23_cyberland)C++17
0 / 100
32 ms7004 KiB
#include <bits/stdc++.h> #include "cyberland.h" using namespace std; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){ vector<pair<int, int> > adj[N]; for(int i = 0; i < M; i++){ adj[x[i]].push_back({y[i], c[i]}); adj[y[i]].push_back({x[i], c[i]}); } long long dist[N]; fill(dist, dist + N, LLONG_MAX); dist[H] = 0; set<pair<long long, int> > s; s.insert({0, H}); while(!s.empty()){ auto p = *s.begin(); s.erase(s.begin()); int u = p.second, curr_d = p.first; for(auto [v, c] : adj[p.second]){ if(curr_d + c < dist[v]){ auto f = s.find(make_pair(dist[v], v)); if(f != s.end()) s.erase(f); dist[v] = curr_d + c; s.insert({dist[v], v}); } } } if(dist[0] == LLONG_MAX) return -1; long long ans = dist[0]; queue<int> q; q.push(0); bool vis[N] = {false}; vis[0] = vis[H] = true; while(!q.empty()){ int u = q.front(); q.pop(); if(!arr[u]) ans = min(ans, dist[u]); for(auto [v, c] : adj[u]) if(!vis[v]) { vis[v] = true; q.push(v); } } return ans; }

Compilation message (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:19:13: warning: unused variable 'u' [-Wunused-variable]
   19 |         int u = p.second, curr_d = p.first;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...