#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include "closing.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define ff first
#define ss second
vector<vector<pair<int,int>>>v;
vector<bool>vis;
int max_score(int N, int X, int Y, long long K,
vector<int> U, vector<int> V, vector<int> W){
v.resize(N);
vis.assign(N,false);
for(int i=0;i<N-1;i++){
v[U[i]].push_back({V[i],W[i]});
v[V[i]].push_back({U[i],W[i]});
}
priority_queue<pair<long long,int>>q;
int ans=2;
vis[X]=true;
vis[Y]=true;
for(auto [z,w]:v[X]) q.push({-w,z});
for(auto [z,w]:v[Y]) q.push({-w,z});
while(!q.empty()){
auto [d,x]=q.top();
q.pop();
if(K+d<0){
break;
}
K+=d;
vis[x]=true;
ans++;
for(auto [z,w]:v[x]) if(!vis[z]) q.push({d-w,z});
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
17124 KB |
Output is correct |
2 |
Correct |
53 ms |
16724 KB |
Output is correct |
3 |
Execution timed out |
1071 ms |
11816 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '19' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '19' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '19' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |