08-图8 How Long Does It Take (25 分)】的更多相关文章

A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. (Quoted from https://en.wikipedia.or…
7-8 哈利·波特的考试(25 分) 哈利·波特要考试了,他需要你的帮助.这门课学的是用魔咒将一种动物变成另一种动物的本事.例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等.反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫.另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将猫变老鼠.老鼠变鱼的魔咒连起来念:hahahehe. 现在哈利·波特的手里有一本教材,里面列出了所有的变形魔咒和能变的动物.老师允许他自己带一只动物去考场,要考察…
1013 Battle Over Cities (25 分)   It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any o…
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if each of them is a vertex cover or not. Input Specif…
A graph which is connected and acyclic can be considered a tree. The hight of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root is called the deepest root. Input Specification: Ea…
It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any other highways to keep the rest of…
图着色问题是一个著名的NP完全问题.给定无向图,,问可否用K种颜色为V中的每一个顶点分配一种颜色,使得不会有两个相邻顶点具有同一种颜色? 但本题并不是要你解决这个着色问题,而是对给定的一种颜色分配,请你判断这是否是图着色问题的一个解. 输入格式: 输入在第一行给出3个整数V(0).E(≥)和K(0),分别是无向图的顶点数.边数.以及颜色数.顶点和颜色都从1到V编号.随后E行,每行给出一条边的两个端点的编号.在图的信息给出之后,给出了一个正整数N(≤),是待检查的颜色分配方案的个数.随后N行,每行…
The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle". In this problem, you are supposed to tell if a given cycle is a Hamiltonian cycle. Input Specif…
The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origin city?" It is an N…
这题用并查集或者dfs都可以做 dfs #include<bits/stdc++.h> using namespace std; ; bool mp[N][N]; int n,m,k; bool vis[N]; void dfs(int v) { vis[v]=true; ;i<=n;i++){ if(mp[v][i]&&!vis[i]){ dfs(i); } } } int main() { fill(mp[],mp[]+N*N,false); scanf("…