Submission #990674

#TimeUsernameProblemLanguageResultExecution timeMemory
990674Ibrohim0704Cyberland (APIO23_cyberland)C++17
0 / 100
924 ms2264 KiB
#include <iostream> #include <vector> #include <queue> #include <limits> using namespace std; struct Node { int country; int passingTime; Node(int c, int t) : country(c), passingTime(t) {} bool operator>(const Node& other) const { return passingTime > other.passingTime; } }; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { priority_queue<Node, vector<Node>, greater<Node>> pq; vector<bool> visited(N, false); pq.push(Node(0, 0)); while (!pq.empty()) { Node current = pq.top(); pq.pop(); if (current.country == H) { return current.passingTime; } visited[current.country] = true; for (int i = 0; i < M; ++i) { int neighbor; int roadTime; if (x[i] == current.country) { neighbor = y[i]; roadTime = c[i]; } else if (y[i] == current.country) { neighbor = x[i]; roadTime = c[i]; } else { continue; } int passingTime = current.passingTime + roadTime; if (arr[neighbor] == 2 && K > 0) { passingTime /= 2; K--; } else if (arr[neighbor] == 0) { passingTime = 0; } if (!visited[neighbor]) { pq.push(Node(neighbor, passingTime)); } } } return -1; }
#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...