博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[ZOJ 1015]Fishing Net(MCS弦图的判定)
阅读量:5831 次
发布时间:2019-06-18

本文共 2127 字,大约阅读时间需要 7 分钟。

Description

In a highly modernized fishing village, inhabitants there make a living on fishery. Their major tools, fishing nets, are produced and fixed by computer. After catching fishes each time, together with plenty of fishes, they will bring back the shabby fishing nets, which might be full of leaks. Then they have to inspect those nets. If there exist large leaks, they have to repair them before launching out again.

Obviously, the smaller the leaks in the fishing nets are, the more fishes they will catch. So after coming back, those fishermen will input the information of the fishing nets into the computer to check whether the nets have leaks.
The checking principle is very simple: The computer regards each fishing net as a simple graph constructed by nodes and edges. In the graph, if any circle whose length (the number of edges) is larger than 3 must has at least one chord, the computer will output "Perfect" indicating that the fishnet has no leaks. Otherwise, "Imperfect" will be displayed and the computer will try to repair the net.
Note: A circle is a closed loop, which starts from one node, passes through other distinct nodes and back to the starting node. A chord is an edge, which connects two different nodes on the circle, but it does not belong to the set of edges on the circle.

 

Solution

PE*1 QvQ

Follow the output for each net with a blank line.

最大势算法 Maximum Cardinality Search

由n到1的顺序给点标号,设label[i]表示i与多少个已标号的点相连,每次选择label[i]最大的未标号点标号

判断序列是否为完美消除

设{vi+1,...,vn}中所有与vi相邻的点依次为vj1,...,vjk。只需判断vj1是否与vj2,...,vjk相邻即可。

#include
#include
#include
#include
#define MAXN 1005using namespace std;int n,m,Map[MAXN][MAXN],label[MAXN],num[MAXN],visited[MAXN];void work(){ for(int i=n;i>0;i--) { int u=0; for(int j=1;j<=n;j++) if(!visited[j]&&(!u||label[j]>label[u]))u=j; visited[u]=1;num[i]=u; for(int j=1;j<=n;j++) { if(Map[u][j]&&!visited[j]) label[j]++; } }}bool judge(){ for(int i=1;i

 

转载于:https://www.cnblogs.com/Zars19/p/6629517.html

你可能感兴趣的文章
在新获取git中项目时出现的问题汇总
查看>>
WEB前端开发人员必看腾讯网无障碍说明
查看>>
jstl 标签
查看>>
mui -div来表示子页面
查看>>
python-install-package-C++编译器问题---05
查看>>
8816
查看>>
Hadoop- Hadoop环境搭建
查看>>
调试技术的优势
查看>>
牛的东西
查看>>
Python基础之杂货铺
查看>>
第二次作业-git的基本操作
查看>>
摘记 史上最强大的40多个纯CSS绘制的图形(一)
查看>>
Android-NDK编译
查看>>
ejoy2d源码阅读笔记1
查看>>
位运算
查看>>
Oracle/PLSQL WHERE CURRENT OF Statement
查看>>
Cucumber capybara 每个Scenario登陆一次
查看>>
jQuery-animate万能动画效果
查看>>
11. Java常用类
查看>>
Android应用程序窗口(Activity)的绘图表面(Surface)的创建过程分析
查看>>