# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957674 | ALTAKEXE | Cyberland (APIO23_cyberland) | C++17 | 26 ms | 7388 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
#define f first
#define s second
using namespace std;
struct T
{
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<T>> 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 t = q.top().second, dist = q.top().f;
q.pop();
if (ans[t] < dist)
continue;
for (auto [v, w] : v[t])
{
if (ans[t] + w < ans[v])
{
ans[v] = ans[t] + 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... |