| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1370645 | leolin0214 | 봉쇄 시간 (IOI23_closing) | C++20 | 57 ms | 20172 KiB |
#include "closing.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#define ff first
#define ss second
using namespace std;
struct Tree {
int n;
vector<vector<pair<int, long long>>> adj;
Tree(int _n) : n(_n), adj(n) {}
void add_edge(int u, int v, long long w) {
adj[u].push_back({v, w});
adj[v].push_back({u, w});
}
int solve(int x, int y, long long k) {
using pii = pair<long long, int>;
priority_queue<pii, vector<pii>, greater<pii>> pq;
pq.push({0, x});
pq.push({0, y});
long long cost = 0;
int ans = 0;
vector<bool> vis(n);
while (pq.size()) {
auto [d, u] = pq.top(); pq.pop();
if ((cost += d) <= k) ans++;
else break;
vis[u] = true;
for (auto [v, w]: adj[u]) {
if (vis[v]) continue;
pq.push({d + w, v});
}
}
return ans;
}
};
int max_score(int N, int X, int Y, long long K,
std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
Tree t(N);
for (int i=0; i<N-1; i++) t.add_edge(U[i], V[i], W[i]);
return t.solve(X, Y, K);
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
