Submission #1208676

#TimeUsernameProblemLanguageResultExecution timeMemory
1208676NeltClosing Time (IOI23_closing)C++20
0 / 100
68 ms28996 KiB
#include "closing.h" #include <bits/stdc++.h> #define ll long long #define endl "\n" using namespace std; const ll N = 2e5 + 5; vector<pair<ll, ll>> g[N]; void dfs(ll v, ll par, vector<ll> &depth) { for (auto [to, w] : g[v]) if (to != par) { depth[to] = depth[v] + w; dfs(to, v, depth); } } vector<ll> getpath(ll x, ll y, vector<ll> &d) { vector<ll> path; while (x != y and path.size() <= d.size()) { path.push_back(x); for (auto [i, w] : g[x]) if (d[i] < d[x]) { x = i; break; } } path.push_back(y); return path; } ll n; int max_score(int N, int X, int Y, long long k, std::vector<int> U, std::vector<int> V, std::vector<int> W) { n = N; for (ll i = 0; i < n; i++) g[i].clear(); for (ll i = 0; i + 1 < n; i++) g[U[i]].push_back(make_pair(V[i], W[i])), g[V[i]].push_back(make_pair(U[i], W[i])); vector<ll> a(n), b(n); dfs(X, -1, a); dfs(Y, -1, b); ll ans = 0, sum = 0; vector<ll> c; for (ll i : a) a.push_back(i); for (ll i : b) b.push_back(i); sort(c.begin(), c.end()); for (ll i : c) { sum += i; if (sum > k) return ans; ans++; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...