이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |