#include <bits/stdc++.h>
#include "closing.h"
using namespace std;
#define int long long
vector<vector<pair<int,int>>> edges;
signed max_score(signed N, signed rootX, signed rootY, long long K, std::vector<signed> U, std::vector<signed> V, std::vector<signed> W){
edges.clear();
edges.resize(N);
for (int i = 0; i < N-1; i++)
{
edges[U[i]].push_back({V[i], W[i]});
edges[V[i]].push_back({U[i], W[i]});
}
vector<int> visited(N);
priority_queue<pair<int,int>> krusk;
krusk.push({0,rootX});
krusk.push({0,rootY});
int sum=0;
int cnt=-2;
while(!krusk.empty()){
int x=krusk.top().second, sumw=abs(krusk.top().first); krusk.pop();
if(sum+sumw>K) continue;
visited[x]=true;
sum+=sumw;
cnt++;
for (auto u : edges[x])
{
int v=u.first,w=u.second;
if(visited[v]) continue;
krusk.push({-(sumw+w), v});
}
}
return (int)cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '3' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
82 ms |
25168 KB |
1st lines differ - on the 1st token, expected: '451', found: '449' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '3' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '3' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '3' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '3' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
1st lines differ - on the 1st token, expected: '6', found: '3' |
2 |
Halted |
0 ms |
0 KB |
- |