Submission #752959

#TimeUsernameProblemLanguageResultExecution timeMemory
752959MohamedFaresNebiliCyberland (APIO23_cyberland)C++17
0 / 100
32 ms6688 KiB
#include <bits/stdc++.h> using namespace std; int N, M, K, H, A[100005]; double D1[100005], D2[100005], D3[100005]; vector<pair<int, int>> adj[100005]; double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { for(int l = 0; l < n; l++) D1[l] = INT_MAX, adj[l].clear(); D1[0] = 0; for(int l = 0; l < m; l++) { adj[x[l]].push_back({y[l], c[l]}); adj[y[l]].push_back({x[l], c[l]}); } priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; pq.push({0, 0}); while(!pq.empty()) { double W = pq.top().first; int U = pq.top().second; pq.pop(); if(U == h) continue; for(auto V : adj[U]) { if(D1[V.first] > W + V.second) { D1[V.first] = W + V.second; if(arr[V.first] == 0) D1[V.first] = 0; pq.push({D1[V.first], V.first}); } } } if(D1[h] == INT_MAX) return -1; return D1[h]; }
#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...