# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037716 | fv3 | Closing Time (IOI23_closing) | C++17 | 87 ms | 26116 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 "closing.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1ll << 60ll;
int max_score(int N, int X, int Y, ll K,
vector<int> U, vector<int> V, vector<int> W)
{
vector<vector<pair<int, ll>>> adj(N);
for (int i = 0; i < U.size(); i++)
{
adj[U[i]].push_back({V[i], W[i]});
adj[V[i]].push_back({U[i], W[i]});
}
priority_queue<pair<ll, int>> q;
q.push({0, X});
q.push({0, Y});
vector<int> visited(N);
vector<ll> dist(N, INF);
dist[X] = 0;
dist[Y] = 0;
int res = 0;
while (!q.empty())
{
int s = q.top().second;
q.pop();
if (visited[s]) continue;
visited[s] = 1;
K -= dist[s];
if (K < 0)
break;
res++;
for (auto node : adj[s])
{
if (!visited[node.first] && dist[s] + node.second < dist[node.first])
{
dist[node.first] = dist[s] + node.second;
q.push({dist[node.first], node.first});
}
}
}
return res;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |