#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
const ll MAXN = 2E5+16;
vector <pair <ll, ll> > adj[MAXN];
int max_score (int n, int u1, int u2, ll k, vi u, vi v, vi w) {
fill(adj, adj+n, vector <pair <ll, ll> > ({}));
for (ll i = 0; i < n-1; i++) {
adj[u[i]].push_back({ v[i], w[i] });
adj[v[i]].push_back({ u[i], w[i] });
}
vll dis(n);
vector <char> vis(n, false);
priority_queue <pair <ll, ll> > pq;
dis[u1] = 0;
dis[u2] = 0;
pq.push({ 0, u1 });
pq.push({ 0, u2 });
ll ans = 0;
while (pq.size()) {
ll u = pq.top().second; pq.pop();
if (k-dis[u] < 0) break;
k -= dis[u];
vis[u] = true;
ans++;
for (auto [v, w] : adj[u]) {
if (vis[v]) continue;
dis[v] = dis[u]+w;
pq.push({ -dis[v], v });
}
}
return int(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
21844 KB |
Output is correct |
2 |
Correct |
71 ms |
22096 KB |
Output is correct |
3 |
Correct |
43 ms |
7508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
3 |
Halted |
0 ms |
0 KB |
- |