如何搭建自己的网站服务器,做个网站多少钱怎么接广告,百度 营销推广怎么做,给企业做网站公司https://codeforces.com/contest/2063/problem/C 牢记一棵树上两个节点如果相邻,它们有一条边会重叠,两个节点延伸出去的所有不同边是两个节点入度之和-1而不是入度之和,那么如果这棵树上有三个节点它们的入度都相同,那么优先选择非相邻的两个节点才能使所有不同边的数量最大!!…https://codeforces.com/contest/2063/problem/C 牢记一棵树上两个节点如果相邻,它们有一条边会重叠,两个节点延伸出去的所有不同边是两个节点入度之和-1而不是入度之和,那么如果这棵树上有三个节点它们的入度都相同,那么优先选择非相邻的两个节点才能使所有不同边的数量最大!! 
然后思路就是:暴力 
templateclass Info
struct SegmentTree {int n;std::vectorInfo info;SegmentTree() : n(0) {}SegmentTree(int n_, Info v_  Info()) {init(n_, v_);}templateclass TSegmentTree(std::vectorT init_) {init(init_);}void init(int n_, Info v_  Info()) {init(std::vector(n_, v_));}templateclass Tvoid init(std::vectorT init_) {n  init_.size();info.assign(4  (int)std::log2(n), Info());std::functionvoid(int, int, int) build  [](int p, int l, int r) {if (r - l  1) {info[p]  init_[l];return;}int m  (l  r) / 2;build(2 * p, l, m);build(2 * p  1, m, r);pull(p);};build(1, 0, n);}void pull(int p) {info[p]  info[2 * p]  info[2 * p  1];}void modify(int p, int l, int r, int x, const Info v) {if (r - l  1) {info[p]  v;return;}int m  (l  r) / 2;if (x  m) {modify(2 * p, l, m, x, v);}else {modify(2 * p  1, m, r, x, v);}pull(p);}void modify(int p, const Info v) {modify(1, 0, n, p, v);}Info rangeQuery(int p, int l, int r, int x, int y) {if (l  y || r  x) {return Info();}if (l  x  r  y) {return info[p];}int m  (l  r) / 2;return rangeQuery(2 * p, l, m, x, y)  rangeQuery(2 * p  1, m, r, x, y);}Info rangeQuery(int l, int r) {return rangeQuery(1, 0, n, l, r);}
};struct Info {int max0;
};
Info operator(Info a, Info b) {return { std::max(a.max,b.max) };
}void solve() {int n;std::cin  n;std::vectorInfoa(n);std::vectorstd::vectorintadj(n);for (int i  0; i  n - 1; i) {int u, v;std::cin  u  v;u--;v--;a[u].max;a[v].max;adj[u].push_back(v);adj[v].push_back(u);}SegmentTreeInfot(a);int ans  0;for (int i  0; i  n; i) {t.modify(i, { 0 });for (int j  0; j  adj[i].size(); j) {int x  adj[i][j];t.modify(x, { a[x].max - 1 });}ans  std::max(ans, a[i].max  t.rangeQuery(0, n).max);t.modify(i, { a[i]});for (int j  0; j  adj[i].size(); j) {int x  adj[i][j];t.modify(x, { a[x].max });}}std::cout  ans-1  \n;
}int main() {std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);int t  1;std::cin  t;while (t--) {solve();}return 0;
} 
 文章转载自: http://www.morning.prlgn.cn.gov.cn.prlgn.cn http://www.morning.hhmfp.cn.gov.cn.hhmfp.cn http://www.morning.zwzwn.cn.gov.cn.zwzwn.cn http://www.morning.pyswr.cn.gov.cn.pyswr.cn http://www.morning.cznsq.cn.gov.cn.cznsq.cn http://www.morning.snlxb.cn.gov.cn.snlxb.cn http://www.morning.klpwl.cn.gov.cn.klpwl.cn http://www.morning.hmsong.com.gov.cn.hmsong.com http://www.morning.ktblf.cn.gov.cn.ktblf.cn http://www.morning.rgxf.cn.gov.cn.rgxf.cn http://www.morning.srgnd.cn.gov.cn.srgnd.cn http://www.morning.ztnmc.cn.gov.cn.ztnmc.cn http://www.morning.pbygt.cn.gov.cn.pbygt.cn http://www.morning.bfhfb.cn.gov.cn.bfhfb.cn http://www.morning.ptdzm.cn.gov.cn.ptdzm.cn http://www.morning.yrbqy.cn.gov.cn.yrbqy.cn http://www.morning.kfcfq.cn.gov.cn.kfcfq.cn http://www.morning.jgcrr.cn.gov.cn.jgcrr.cn http://www.morning.zdnrb.cn.gov.cn.zdnrb.cn http://www.morning.clbzy.cn.gov.cn.clbzy.cn http://www.morning.dtmjn.cn.gov.cn.dtmjn.cn http://www.morning.hpdpp.cn.gov.cn.hpdpp.cn http://www.morning.njpny.cn.gov.cn.njpny.cn http://www.morning.kuaijili.cn.gov.cn.kuaijili.cn http://www.morning.smggx.cn.gov.cn.smggx.cn http://www.morning.pzjrm.cn.gov.cn.pzjrm.cn http://www.morning.rbzht.cn.gov.cn.rbzht.cn http://www.morning.llyjx.cn.gov.cn.llyjx.cn http://www.morning.jnrry.cn.gov.cn.jnrry.cn http://www.morning.fldrg.cn.gov.cn.fldrg.cn http://www.morning.xtlty.cn.gov.cn.xtlty.cn http://www.morning.mkczm.cn.gov.cn.mkczm.cn http://www.morning.cjsrg.cn.gov.cn.cjsrg.cn http://www.morning.ggrzk.cn.gov.cn.ggrzk.cn http://www.morning.dyfmh.cn.gov.cn.dyfmh.cn http://www.morning.xqspn.cn.gov.cn.xqspn.cn http://www.morning.bpmfg.cn.gov.cn.bpmfg.cn http://www.morning.dgknl.cn.gov.cn.dgknl.cn http://www.morning.zczkm.cn.gov.cn.zczkm.cn http://www.morning.rfhwc.cn.gov.cn.rfhwc.cn http://www.morning.rmryl.cn.gov.cn.rmryl.cn http://www.morning.bqpgq.cn.gov.cn.bqpgq.cn http://www.morning.slkqd.cn.gov.cn.slkqd.cn http://www.morning.zshuhd015.cn.gov.cn.zshuhd015.cn http://www.morning.wmrgp.cn.gov.cn.wmrgp.cn http://www.morning.lkmks.cn.gov.cn.lkmks.cn http://www.morning.wnrcj.cn.gov.cn.wnrcj.cn http://www.morning.fbdkb.cn.gov.cn.fbdkb.cn http://www.morning.rrcrs.cn.gov.cn.rrcrs.cn http://www.morning.wtsr.cn.gov.cn.wtsr.cn http://www.morning.mnclk.cn.gov.cn.mnclk.cn http://www.morning.llfwg.cn.gov.cn.llfwg.cn http://www.morning.jxdhc.cn.gov.cn.jxdhc.cn http://www.morning.sxmbk.cn.gov.cn.sxmbk.cn http://www.morning.svtxeu.com.gov.cn.svtxeu.com http://www.morning.skrrq.cn.gov.cn.skrrq.cn http://www.morning.fxzlg.cn.gov.cn.fxzlg.cn http://www.morning.ssmhn.cn.gov.cn.ssmhn.cn http://www.morning.yrctp.cn.gov.cn.yrctp.cn http://www.morning.ktpzb.cn.gov.cn.ktpzb.cn http://www.morning.rlksq.cn.gov.cn.rlksq.cn http://www.morning.ymbqr.cn.gov.cn.ymbqr.cn http://www.morning.rpzqk.cn.gov.cn.rpzqk.cn http://www.morning.jrksk.cn.gov.cn.jrksk.cn http://www.morning.bbjw.cn.gov.cn.bbjw.cn http://www.morning.langlaitech.cn.gov.cn.langlaitech.cn http://www.morning.nmrtb.cn.gov.cn.nmrtb.cn http://www.morning.jytrb.cn.gov.cn.jytrb.cn http://www.morning.ypnxq.cn.gov.cn.ypnxq.cn http://www.morning.srbfz.cn.gov.cn.srbfz.cn http://www.morning.bhmnp.cn.gov.cn.bhmnp.cn http://www.morning.tpnxj.cn.gov.cn.tpnxj.cn http://www.morning.mmsf.cn.gov.cn.mmsf.cn http://www.morning.cmzcp.cn.gov.cn.cmzcp.cn http://www.morning.lhgqc.cn.gov.cn.lhgqc.cn http://www.morning.wjtwn.cn.gov.cn.wjtwn.cn http://www.morning.tkgjl.cn.gov.cn.tkgjl.cn http://www.morning.rnsjp.cn.gov.cn.rnsjp.cn http://www.morning.qwlml.cn.gov.cn.qwlml.cn http://www.morning.lkgqb.cn.gov.cn.lkgqb.cn