# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037893 | Zicrus | Closing Time (IOI23_closing) | C++17 | 94 ms | 28964 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>
#include "closing.h"
using namespace std;
typedef long long ll;
int max_score(int n, int x, int y, ll k, vector<int> u, vector<int> v, vector<int> w) {
priority_queue<pair<ll, ll>> finalQ;
vector<vector<pair<ll, ll>>> adj(n);
for (int i = 0; i < w.size(); i++) {
adj[u[i]].push_back({-w[i], v[i]});
adj[v[i]].push_back({-w[i], u[i]});
}
vector<ll> distX(n, 1ll << 62ll), distY(n, 1ll << 62ll);
vector<bool> vstX(n), vstY(n);
priority_queue<pair<ll, ll>> q;
distX[x] = distY[y] = 0;
q.push({0, x});
while (!q.empty()) {
ll node = q.top().second; q.pop();
if (vstX[node]) continue;
vstX[node] = true;
for (auto &e : adj[node]) {
distX[e.second] = min(distX[e.second], distX[node] - e.first);
q.push({-distX[e.second], e.second});
}
}
q.push({0, y});
while (!q.empty()) {
ll node = q.top().second; q.pop();
if (vstY[node]) continue;
vstY[node] = true;
for (auto &e : adj[node]) {
distY[e.second] = min(distY[e.second], distY[node] - e.first);
q.push({-distY[e.second], e.second});
}
}
for (int i = 0; i < n; i++) {
finalQ.push({-min(distX[i], distY[i]), i});
}
ll res = 0;
while (!finalQ.empty()) {
ll dist = -finalQ.top().first; finalQ.pop();
if (dist > k) return res;
k -= dist;
res++;
}
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... |