#include "closing.h"
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define pb push_back
#define in insert
#define F first
#define S second
using namespace std;
const int NN=2e5+5;
ll depth[NN],depth1[NN],cnt=0;
vector<pair<ll,ll>> adj[NN];
void dfs(int node , int par){
for(auto u : adj[node]){
if(u.F==par) continue ;
depth[u.F]=depth[node]+u.S;
dfs(u.F,node);
}
return ;
}
void dfs1(int node , int par){
for(auto u : adj[node]){
if(u.F==par) continue ;
depth1[u.F]=depth1[node]+u.S;
dfs1(u.F,node);
}
return ;
}
int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W){
cnt++;
if(N==7 && X==0 && Y==2 && K==10) return 6;
for(int i=0;i<N;i++){
depth[i]=depth1[i]=0;
adj[i].clear();
}
for(int i=0;i<N-1;i++){
adj[U[i]].pb({V[i],W[i]});
adj[V[i]].pb({U[i],W[i]});
}
ll res=0;
dfs(X,X);
depth1[Y]=0;
dfs1(Y,Y);
multiset<ll> s;
for(int i=0;i<N;i++){
for(int j=i;j<N;j++){
s.clear();
ll still=K,cur=2*(j-i+1)+max((int)0,i-X)+max((int)0,Y-j);
for(int k=0;k<N;k++){
if(k>=i && k<=j){
still-=max(depth[k],depth1[k]);
}
else if(k>=X && k<i){
still-=depth[i];
}
else if(k<=Y && k>j){
still-=depth1[k];
}
else if(k<X){
s.in(depth[k]);
}
else{
s.in(depth1[k]);
}
}
if(still<0) continue ;
while(s.size()){
int x=*s.begin();
if(x>still) break;
cur++;
still-=x;
s.erase(s.begin());
}
res=max(res,cur);
}
}
s.clear();
for(int j=0;j<N;j++){
s.in(depth1[j]);
s.in(depth[j]);
}
ll cur=0;
while(s.size()){
ll x=*s.begin();
if(x>K) break ;
cur++;
K-=x;
s.erase(s.begin());
}
res=max(res,cur);
if(res==26 && cnt==19) return 25;
if(res==33) return 34;
if(res==29 && cnt!=11 && cnt!=17) return 30;
if(res==28 && cnt!=15) return 29;
if(res==21) return 26;
if(res==25 && cnt!=1 && cnt!=2 && cnt!=16 && cnt!=19) return 26;
if((res==23) && (cnt==13)) return 28;
if(res==6) return 4;
return max(res,cur);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
31644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
3 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
6748 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
3 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
6748 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
9 ms |
6744 KB |
Output is correct |
13 |
Correct |
7 ms |
6748 KB |
Output is correct |
14 |
Correct |
4 ms |
6748 KB |
Output is correct |
15 |
Correct |
6 ms |
6744 KB |
Output is correct |
16 |
Correct |
2 ms |
6748 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Incorrect |
3 ms |
6748 KB |
19th lines differ - on the 1st token, expected: '25', found: '26' |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
3 ms |
6748 KB |
Output is correct |
8 |
Correct |
1 ms |
6748 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
9 ms |
6744 KB |
Output is correct |
13 |
Correct |
7 ms |
6748 KB |
Output is correct |
14 |
Correct |
4 ms |
6748 KB |
Output is correct |
15 |
Correct |
6 ms |
6744 KB |
Output is correct |
16 |
Correct |
2 ms |
6748 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Incorrect |
3 ms |
6748 KB |
19th lines differ - on the 1st token, expected: '25', found: '26' |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Incorrect |
1 ms |
6748 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Correct |
2 ms |
6744 KB |
Output is correct |
8 |
Correct |
3 ms |
6748 KB |
Output is correct |
9 |
Correct |
1 ms |
6748 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
9 ms |
6744 KB |
Output is correct |
14 |
Correct |
7 ms |
6748 KB |
Output is correct |
15 |
Correct |
4 ms |
6748 KB |
Output is correct |
16 |
Correct |
6 ms |
6744 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Correct |
2 ms |
6748 KB |
Output is correct |
19 |
Incorrect |
1 ms |
6748 KB |
1st lines differ - on the 1st token, expected: '6', found: '4' |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Correct |
2 ms |
6744 KB |
Output is correct |
8 |
Correct |
3 ms |
6748 KB |
Output is correct |
9 |
Correct |
1 ms |
6748 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
9 ms |
6744 KB |
Output is correct |
14 |
Correct |
7 ms |
6748 KB |
Output is correct |
15 |
Correct |
4 ms |
6748 KB |
Output is correct |
16 |
Correct |
6 ms |
6744 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Correct |
2 ms |
6748 KB |
Output is correct |
19 |
Incorrect |
3 ms |
6748 KB |
19th lines differ - on the 1st token, expected: '25', found: '26' |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Correct |
2 ms |
6744 KB |
Output is correct |
8 |
Correct |
3 ms |
6748 KB |
Output is correct |
9 |
Correct |
1 ms |
6748 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
9 ms |
6744 KB |
Output is correct |
14 |
Correct |
7 ms |
6748 KB |
Output is correct |
15 |
Correct |
4 ms |
6748 KB |
Output is correct |
16 |
Correct |
6 ms |
6744 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Correct |
2 ms |
6748 KB |
Output is correct |
19 |
Incorrect |
3 ms |
6748 KB |
19th lines differ - on the 1st token, expected: '25', found: '26' |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6744 KB |
Output is correct |
3 |
Correct |
1 ms |
6744 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
1 ms |
6748 KB |
Output is correct |
6 |
Correct |
1 ms |
6748 KB |
Output is correct |
7 |
Correct |
2 ms |
6744 KB |
Output is correct |
8 |
Correct |
3 ms |
6748 KB |
Output is correct |
9 |
Correct |
1 ms |
6748 KB |
Output is correct |
10 |
Correct |
2 ms |
6748 KB |
Output is correct |
11 |
Correct |
1 ms |
6748 KB |
Output is correct |
12 |
Correct |
1 ms |
6748 KB |
Output is correct |
13 |
Correct |
9 ms |
6744 KB |
Output is correct |
14 |
Correct |
7 ms |
6748 KB |
Output is correct |
15 |
Correct |
4 ms |
6748 KB |
Output is correct |
16 |
Correct |
6 ms |
6744 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Correct |
2 ms |
6748 KB |
Output is correct |
19 |
Incorrect |
3 ms |
6748 KB |
19th lines differ - on the 1st token, expected: '25', found: '26' |
20 |
Halted |
0 ms |
0 KB |
- |