UVa 10720 - Graph Construction】的更多相关文章

题目链接: 传送门 Graph Construction Time Limit: 3000MS     Memory Limit: 65536K Description Graph is a collection of edges E and vertices V. Graph has a wide variety of applications in computer. There are different ways to represent graph in computer. It can…
题目链接: 题目 Graph Construction Time limit: 3.000 seconds 问题描述 Graph is a collection of edges E and vertices V. Graph has a wide variety of applications in computer. There are different ways to represent graph in computer. It can be represented by adjace…
题目大意:给n个整数, 分别代表图中n个顶点的度,判断是否能构成一张图. 看到这个题后,除了所有数之和应该为偶数之外,没有别的想法了,只好在网上搜解题报告了.然后了解了Havel-Hakimi定理.之后的事情就简单了. #include <cstdio> #include <algorithm> #include <functional> using namespace std; #define MAXN 10000+10 int a[MAXN]; int n; boo…
Luogu传送门(UVA常年上不去) 题意:求一个度序列是否可变换为一个简单图.$\text{序列长度} \leq 10000$ 题目看起来很简单,但是还是有一些小细节需要注意首先一个简单的结论:一张图的所有点的度数之和为偶数,因为每一条边都会对度数和产生$2$的贡献.通过这一个结论可以判断掉很多的非法情况.当然如果做到这里就天真地交上去了,在若干秒之后就会给你显示一个喜庆的$WA$,因为我们还有一个很重要的因素没有考虑:图是一个简单图.简单图意味着不能有重边和自环,而上面的那个结论不足以判断图…
Description You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the graph and the only available colors are black and white. The coloring of the graph is called optimal if a maximum…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4261 题意: 输入一个h行w列的字符矩阵,草地用“#”表示,洞用“.”表示.你可以把草改成洞,每格花费为d,也可以把洞填上草,每格花费为f.最后还需要在草和洞之间修围栏,每条边的花费为b.整个矩阵第一行/列和最后一行/列必须都是草.求最小花费.2≤w,h≤50,1≤d, f, b≤…
Pool construction You are working for the International Company for Pool Construction, a construction company whichspecializes in building swimming pools. A new client wants to build several new pool areas.A pool area is a rectangular grid of w × h s…
题意: 给一个h*w的矩阵,每个格子中是'#'和'.'两个符号之一,分别代表草和洞.现在要将洞给围起来(将草和洞分离),每条边需花费b元(即将一个洞包起来需要4边,将2个连续的洞包起来需要6边,省了2条边).有个特殊能力,能将洞变成草,花费f.当然也能将草变成洞,花费d.围起洞来需要多少花费.矩阵四周最边边的格子都必须是草,即出现洞就必须转草. 转换:洞--->草--->洞      f   d   (元/格) 围洞: b元/边. 思路: 如果能够尽量让洞都靠在一起,那肯定是最小花费,因为少了…
题意:图上的点染色,给出的边的两个点不能都染成黑色,问最多可以染多少黑色. 很水的一题,用dfs回溯即可.先判断和当前点相连的点是否染成黑色,看这一点是否能染黑色,能染色就分染成黑色和白色两种情况递归,如果不能就单递归白色. 代码: #include <cstdio> #include <cstring> const int maxn = 110; int cas, v, e, M; bool g[maxn][maxn]; int color[maxn], rec[maxn]; v…
题目大意:给你一个无向图的顶点和边集,让你求图中连通分量的个数.使用并查集解决. #include <cstdio> #include <cstring> #define MAXN 30 bool G[MAXN][MAXN]; int p[MAXN]; int find(int x) { return x == p[x] ? x : p[x]=find(p[x]); } int main() { #ifdef LOCAL freopen("in", "…