题目描述 给定一棵无根树,边权都是\(1\),请去掉一条边并加上一条新边,定义直径为最远的两个点的距离,请输出所有可能的新树的直径的最小值和最大值。 input 第一行包含一个正整数$ n(2<=n<=500000) $,...
单调性显然,双端队列队列维护严格单调递减手写双端队列真的可恶。 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define R...