hdu6029 Graph Theory (2017女生赛)

Graph Theory

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 167    Accepted Submission(s): 84


Problem Description
Little Q loves playing with different kinds of graphs very much. One day he thought about an interesting category of graphs called ``Cool Graph'', which are generated in the following way:
Let the set of vertices be {1, 2, 3, ..., n }. You have to consider every vertice from left to right (i.e. from vertice 2 to n ). At vertice i , you must make one of the following two decisions:
(1) Add edges between this vertex and all the previous vertices (i.e. from vertex 1 to i1 ).
(2) Not add any edge between this vertex and any of the previous vertices.
In the mathematical discipline of graph theory, a matching in a graph is a set of edges without common vertices. A perfect matching is a matching that each vertice is covered by an edge in the set.
Now Little Q is interested in checking whether a ''Cool Graph'' has perfect matching. Please write a program to help him.

Input
The first line of the input contains an integer T(1T50) , denoting the number of test cases.
In each test case, there is an integer n(2n100000) in the first line, denoting the number of vertices of the graph.
The following line contains n1 integers a2,a3,...,an(1ai2) , denoting the decision on each vertice.

Output
For each test case, output a string in the first line. If the graph has perfect matching, output ''Yes'', otherwise output ''No''.

Sample Input
  
  
3 2 1 2 2 4 1 1 2
 
Sample Output
  
  
Yes No No
 
Source
 

再说题意之前我要先学个单词:

所以说 a set of 的意思是 一组...
只需找到的是一组边使得满足perfect matching!

题意:有n个点让你进行操作,从第二点开始,你可以开始操作,并且只能操作其中的任意一个,输入给出了点数和各点的操作,现在要求的就是是否有一组边满足perfect matching;perfect matching 的意思就是任何一个点当且仅当被一条边所覆盖;
两种操作分别是,1:当前点和所有前面的点都要连;2:当前点与前面任意点都不去相连!
思路:完美匹配就是: 。——。 。——。...... 这种方式;所以点数必须为偶数个。第一个点没有操作,可以假设它的操作为2,然后后面遇到一个1就和前面的2匹配一下,作何如果都匹配成功,就ok啦!
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100005;
typedef long long ll;
const ll tomod=1e9+7;

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n,x;
        int flag2=1;
        scanf("%d",&n);

        for(int i=2;i<=n;i++)
        {
            scanf("%d",&x);
            if(x==1)
            {
                if(flag2>0)
                    flag2--;
                else
                    flag2++;
            }
            else if(x==2)
                flag2++;
        }

        if(flag2!=0||n%2!=0)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


Graph Theory Authors: Adrian Bondy, U.S.R Murty Publisher: Springer; 3rd Corrected Printing edition (Aug 14 2008) ISBN-10: 1846289696 ISBN-13: 978-1846289699 = Product Description = The primary aim of this book is to present a coherent introduction to graph theory, suitable as a textbook for advanced undergraduate and beginning graduate students in mathematics and computer science. It provides a systematic treatment of the theory of graphs without sacrificing its intuitive and aesthetic appeal. Commonly used proof techniques are described and illustrated. The book also serves as an introduction to research in graph theory. = Table of Contents = Graphs - Subgraphs - Connected Graphs - Trees - Separable and Nonseparable Graphs - Tree-Search Algorithms - Flows in Networks - Complexity of Algorithms - Connectivity - Planar Graphs - The Four-Colour Problem - Stable Sets and Cliques - The Probabilistic Method - Vertex Colourings - Colourings of Maps - Matchings - Edge Colourings - Hamilton Cycles - Coverings and Packings in Directed Graphs - Electrical Networks - Integer Flows and Coverings - Unsolved Problems - References - Glossary - Index = Reviews = For more than three decades, the authors' Graph Theory with Applications (1976) has served as perhaps the classic introduction to graph theory. With happy shock, the reader learns that Bondy and Murty have updated the book, doubling its size. Three decades would count as a long time in the life of any active scientific pursuit, but the original year of publication saw the solution to the four-color conjecture that catalyzed a vast revitalization of graph theory. Graph theory, moreover, now has intimate interactions with computer science, practical and theoretical: three decades ago, computer networks barely existed and the founding papers of complexity theory had just appeared. Connections between graph theory and probability have also undergone a revolution. In short, the passage of time has transformed this subject in these and other ways, and the authors have transformed their book accordingly. They do, by choice, largely omit the theory of graph minors (developed by Paul Seymour and Neil Robertson and followers), which certainly now deserves a monographic treatment of its own. Summing up: Recommended. Lower-division undergraduate through professional collections. CHOICE This book is a follow-on to the authors' 1976 text, Graphs with Applications. What began as a revision has evolved into a modern, first-class, graduate-level textbook reflecting changes in the discipline over the past thirty years... This text hits the mark by appearing in Springer’s Graduate Texts in Mathematics series, as it is a very rigorous treatment, compactly presented, with an assumption of a very complete undergraduate preparation in all of the standard topics. While the book could ably serve as a reference for many of the most important topics in graph theory, it fulfills the promise of being an effective textbook. The plentiful exercises in each subsection are divided into two groups, with the second group deemed "more challenging". Any exercises necessary for a complete understanding of the text have also been marked as such. There is plenty here to keep a graduate student busy, and any student would learn much in tackling a selection of the exercises... Not only is the content of this book exceptional, so too is its production. The high quality of its manufacture, the crisp and detailed illustrations, and the uncluttered design complement the attention to the typography and layout. Even in simple black and white with line art, it is a beautiful book. SIAM Book Reviews "A text which is designed to be usable both for a basic graph theory course … but also to be usable as an introduction to research in graph theory, by including more advanced topics in each chapter. There are a large number of exercises in the book … . The text contains drawings of many standard interesting graphs, which are listed at the end." (David B. Penman, Zentralblatt MATH, Vol. 1134 (12), 2008) MathSciNet Reviews "The present volume is intended to serve as a text for "advanced undergraduate and beginning graduate students in mathematics and computer science" (p. viii). It is well suited for this purpose. The writing is fully accessible to the stated groups of students, and indeed is not merely readable but is engaging… Even a complete listing of the chapters does not fully convey the breadth of this book… For researchers in graph theory, this book offers features which parallel the first Bondy and Murty book: it provides well-chosen terminology and notation, a multitude of especially interesting graphs, and a substantial unsolved problems section…One-hundred unsolved problems are listed in Appendix A, a treasure trove of problems worthy of study… (In short) this rewrite of a classic in graph theory stands a good chance of becoming a classic itself." "The present volume is intended to serve as a text for ‘advanced undergraduate and beginning graduate students in mathematics and computer science’ … . The writing is fully accessible to the stated groups of students, and indeed is not merely readable but is engaging. The book has many exercise sets, each containing problems … ." (Arthur M. Hobbs, Mathematical Reviews, Issue 2009 C) "A couple of fantastic features: Proof techniques: I love these nutshelled essences highlighted in bordered frames. They look like pictures on the wall and grab the view of the reader. Exercises: Their style, depth and logic remind me of Lovász’ classical exercise book. Also the fact that the name of the author is bracketed after the exercise…Figures: Extremely precise and high-tech…The book contains very recent results and ideas. It is clearly an up-to-date collection of fundamental results of graph theory…All-in-all, it is a marvelous book." (János Barát, Acta Scientiarum Mathematicarum, Vol. 75, 2009)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值