#include "closing.h"
#include<bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz(x) ll(x.size())
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, ll> ii;
const int MAX=1e6;
const ll mod=1e9+7;
ll distx[MAX], disty[MAX];
vector<ii>gfo[MAX];
vector<ll> ans;
void dfsx(int u, int f){
for(auto x:gfo[u]){
int v=x.ff;
ll w1=x.ss;
if(v!=f){
distx[v]=distx[u]+w1;
dfsx(v,u);
}
}
return;
}
void dfsy(int u, int f){
for(auto x:gfo[u]){
int v=x.ff;
ll w1=x.ss;
if(v!=f){
disty[v]=disty[u]+w1;
dfsy(v,u);
}
}
return;
}
void clen(int n){
ans.clear();
for(int i=0; i<=n; i++){
gfo[i].clear();
distx[i]=0;
disty[i]=0;
}
return;
}
int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W){
for(ll i=0; i<sz(U) ; i++){
gfo[U[i]].pb({V[i],W[i]});
gfo[V[i]].pb({U[i],W[i]});
}
dfsx(X,X);
dfsy(Y,Y);
for(int i=0; i<N; i++){
ans.pb(distx[i]);
ans.pb(disty[i]);
}
sort(all(ans));
ll cont=0, sum=0;
for(int x:ans){
sum+=x;
if(sum<=K)cont++;
else break;
}
clen(N);
return cont;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
48324 KB |
Output is correct |
2 |
Correct |
131 ms |
50864 KB |
Output is correct |
3 |
Correct |
74 ms |
26380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
23764 KB |
Output is correct |
2 |
Incorrect |
10 ms |
23792 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
23764 KB |
Output is correct |
2 |
Incorrect |
10 ms |
23792 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
23764 KB |
Output is correct |
2 |
Incorrect |
10 ms |
23792 KB |
1st lines differ - on the 1st token, expected: '30', found: '24' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |