QWQ不得不说 \(cf\)的\(edu\ round\)出这种东西 有点太恶心了 题目大意:给你\(n\)个点,告诉你每个点的最大度数值(也就是说你的度数要小于等于这个),让你构造一个无向图,使其满足直径最大且包含所有点 一看就是个构造题 QWQ但是细节非常多. 大致上的思路就是,我们考虑把度数大于1的点拿出来,然后构成一条链,剩下的往这条链上挂就行,但是挂的时候要注意,优先往最头上的两个点挂,因为这样可以扩大直径,然后搞一搞就好 QWQ (其实是强行凑博客文章数目) 记得特判一下只有一个度数…
题目描述 Description Graph constructive problems are back! This time the graph you are asked to build should match the following properties. The graph is connected if and only if there exists a path between every pair of vertices. The diameter (aka "long…
D. Maximum Diameter Graph time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Graph constructive problems are back! This time the graph you are asked to build should match the following properties…
D. Maximum Diameter Graph 题目链接:https://codeforces.com/contest/1082/problem/D 题意: 给出n个点的最大入度数,要求添加边构成一个无环无向无重边的图,并且最大化图中的最短路径. 题解: 要求最短路径最大,我们会想到把每一个允许入度可以大于1的点先连起来,形成一个”链“,当前肯定满足条件,并且两端点的最短路径长度是所有情况中最大的. 然后对于入度为1的点,先尽量考虑放在链的两端,然后再在中间随便插入. 代码如下: 先附上自己…
Graph constructive problems are back! This time the graph you are asked to build should match the following properties. The graph is connected if and only if there exists a path between every pair of vertices. The diameter (aka "longest shortest path…
题意:给出n个点的度数列 上限(实际点可以小于该度数列)问可以构造简单路最大长度是多少(n个点要连通 不能有平行边.重边) 思路:直接构造一条长链  先把度数为1的点 和度数大于1的点分开  先把度数大于1的点连在一起 然后把度数为1的点连在两边可以涨最多2的长度(如果有大于等于2的度数为1的点) 随后就涨不了长度了,还要把度数为1的点接在链上 判断是否可以构成这样一颗树 (在while里面少写了度数-- WA了两次7 QAQ) #include<bits/stdc++.h> #define…
<题目链接> 题目大意:给你一些点的最大度数,让你构造一张图,使得该图的直径最长,输出对应直径以及所有的边. 解题分析:一道比较暴力的构造题,首先,我们贪心的想,要使图的直径最长,肯定是尽可能的将所有的顶点连在同一条链上,并且,所有度数为1的点都只能作为最外围的点.所以,基本思想就是先将两个度为1的顶点放在链的两端(如果有的话),然后所有度>=2的点放在链的中间,建好链之后,再将多余的度为1的点挂在链上最大度数未满的点上. #include <bits/stdc++.h> u…
题目传送门 题意:现在有n个点,每个点的度数最大为di,现在要求你构成一棵树,求直径最长. 题解:把所有度数为2的点先扣出来,这些就是这颗树的主干,也就是最长的距离. 然后我们把度数为2的点连起来,之后就处理1的点,先在主干的最左边和最右边加上新的点,这样可以使得直径边长. 然后其他的点随便放就好了. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","…
D. Maximum Diameter Graph time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Graph constructive problems are back! This time the graph you are asked to build should match the following proper…
A. Snacktower time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. S…