// #include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<vector<pair<int,int>>>g;
int max_score(int N, int X, int Y, long long K,vector<int> U, vector<int> V, vector<int> W)
{
int n=N;
vector<ll>dis;
g.resize(n,vector<pair<int,int>>());
for(int i=0;i<n;i++){
g[U[i]].pb({V[i],W[i]});
g[V[i]].pb({U[i],W[i]});
}
queue<pair<pair<int,int>,ll>>q;
pair<pair<int,int>,ll>one={{X,X},0},two={{Y,Y},0};
q.push(one);
q.push(two);
while(!q.empty()){
int p=q.front().first.first;
int v=q.front().first.second;
ll cur=q.front().second;
q.pop();
for(auto i:g[v]){
if(i.first==p)continue;
// if(cur+i.second>K)break;
dis.pb(cur+i.second);
pair<pair<int,int>,ll>temp={{v,i.first},i.second+cur};
q.push(temp);
}
}
int ans=0;
sort(dis.begin(),dis.end());
for(auto i:dis){
if(i>K)break;
K-=i;ans++;
}
return ans+2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
178 ms |
33596 KB |
Output is correct |
2 |
Correct |
195 ms |
33120 KB |
Output is correct |
3 |
Execution timed out |
1132 ms |
1050124 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |