B. Destruction of a Tree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any ot…
B. Destruction of a Tree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any ot…
You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges). A vertex can be destroyed if this vertex has even degree. If you destroy a vertex, all edges connect…
题意:给你一棵树, 只能删度数为偶数的点, 问你能不能将整个图删完, 如果能输入删除的顺序. 思路:对于一棵树来说, 如果里面的点的个数是偶数个则肯定不可能, 偶数个点有奇数条边,而你每次删只能删偶数条边. 那么我们对于每个父亲儿子来说, 如果儿子的子树的大小为奇数, 那么肯定先删父亲, 反之先删儿子, 建立关系图, 跑一遍拓扑序就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se secon…
A - Splits 题意 将一个正整数拆分成若干个正整数的和,从大到小排下来,与第一个数字相同的数字的个数为这个拆分的权重. 问\(n\)的所有拆分的不同权重可能个数. 思路 全拆成1,然后每次将2个1换成1个2,即每次2的个数增加1. 共有1+n/2种. Code #include <bits/stdc++.h> #define F(i, a, b) for (int i = (a); i < (b); ++i) #define F2(i, a, b) for (int i = (a…