Submission #971568

#TimeUsernameProblemLanguageResultExecution timeMemory
971568NomioCyberland (APIO23_cyberland)C++17
0 / 100
178 ms6808 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<bool> V(100000, 0); vector<pair<int, int>> v[100000]; vector<int> x, y, c, a; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> a) { for(int i = 0; i < n; i++) { if(a[i] == 0) { V[i] = 1; } else { V[i] = 0; } } for(int i = 0; i < m; i++) { v[x[i]].push_back({y[i], c[i]}); v[y[i]].push_back({x[i], c[i]}); } priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; vector<ll> dis(n, 1e18); dis[0] = 0; pq.push({0, 0}); while(!pq.empty()) { ll x = pq.top().first; int y = pq.top().second; pq.pop(); if(dis[y] != x) continue; for(pair<int, int> p : v[y]) { int X = p.first; int Y = p.second; if(V[X] && dis[X] != 0) { dis[X] = 0; pq.push({0, X}); } else if(dis[X] > dis[y] + Y) { dis[X] = dis[y] + Y; pq.push({dis[X], X}); } } } if(dis[h] == 1e18) { return -1; } else { return dis[h]; } } // //int main() { // cout << solve(4, 4, 30, 3, {0, 0, 1, 2}, {1, 2, 3, 3}, {5, 4, 2, 4}, {1, 0, 2, 1}) << '\n'; //}
#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...