# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957672 | ALTAKEXE | Cyberland (APIO23_cyberland) | C++17 | 25 ms | 7384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct node
{
ll b, w;
};
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr)
{
vector<vector<node>> v(N);
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]});
}
vector<ll> ans(N, LLONG_MAX);
int st = 0;
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> Q;
ans[st] = 0;
Q.push({0, st});
for (int i = 0; i < v.size(); i++)
{
if (i == st)
continue;
if (arr[i] == 0)
{
ans[i] = 0;
Q.push({0, st});
}
}
while (!Q.empty())
{
ll node = Q.top().second, dist = Q.top().first;
Q.pop();
if (ans[node] < dist)
continue;
for (auto [v, w] : v[node])
{
if (ans[node] + w < ans[v])
{
ans[v] = ans[node] + w;
Q.push({ans[v], v});
}
}
}
return ans[H];
}
Compilation message (stderr)
# | 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... |