E. Sonya and Ice Cream time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Sonya likes ice cream very much. She eats it even during programming competitions. That is why the girl decided that…
题面在这里! 挺智障的一个二分...我还写了好久QWQ,退役算啦 题解见注释... /* 先对每个点记录 向子树外的最长路 和 向子树内最长路,然后二分. 二分的时候枚举链的LCA直接做就好啦. */ #include<bits/stdc++.h> #define ll long long using namespace std; #define pb push_back const int N=100005,B=2333333; inline int read(){ int x=0; cha…
$des$ 给定一棵 n 个节点的树,你可以进行 n ? 1 次操作,每次操作步骤如下:选择 u,v 两个度数为 1 的节点.将 u,v 之间的距离加到 ans 上.将 u 从树上删除.求一个操作序列使得 ans 最大. $sol$ 先把直径拿出来,将直径外的点一个一个的和直径中的某一个端点配对并删掉.最后再将直径删掉.这样就是对的.如果当前直径外已经没有点了,那么显然只能将直径的端点删掉.否则一定不会去删直径的端点.因为先删一个直径外的点再删直径端点一定是不劣于先删直径端点再删这个直径外的点的…