# "And look up" hdu 1272 little Greek Maze

Source: Internet
Author: User

"and look Up" hdu 1272 little Greek MazeAnd check the collection--and check the forest without ring and connected Main TopicGive you a connection relationship. Constructs a graph that determines whether the graph is non-cyclic and satisfies connectivity.

talk about the idea.① has no ring: (A, B) the element A, the root node is the same, the same merged edge will become a ring, do not meet the topic requirements ② Connectivity: Record the node before the last node = = The number of its own node, just 1 is a connected forest! ★ Again later and check set initialization i < _max, this problem has the equal sign on WA, do not know why?!!

Reference Code
``//#pragma comment (linker, "/stack:1024000000,1024000000")#include <bits/stdc++.h>#define CLR (k,v) memset (k,v,sizeof (k) )using namespace STD;Const int_max =1e5+Ten;intA,b,pre[_max];BOOLOk,v[_max];voidInit () { for(inti =1; i < _max; + + i) pre[i] = i;}intFindintx) {//check, the root node of element x returnPRE[X] = = x? X:PRE[X] = find (Pre[x]);}voidJoinintAintb) {//And, Edge (A, B)  intx = Find (a), y = find (b);if(x! = y) pre[x] = y;ElseOK =false;//Plus (A, b) a loop appears}intMain () {#ifndef Online_judgeFreopen ("Input.txt","R", stdin);#endif //Online_judge   while(scanf("%d%d", &a,&b) = =2){if(A = =-1&& b = =-1) Break;    Init (); OK =true; CLR (V,0); while(A! =0&& B! =0) {Join (A, b); V[a] = v[b] =1;scanf("%d%d", &a,&b); }intCNT =0; for(inti =1; i < _max; + + i)if(V[i] = =1&&pre[i] = = i) cnt + +;if(CNT >1) OK =false;//Only one connected branch    puts(OK?)"Yes":"No"); }return 0;}``
• Bold `Ctrl + B`
• Italic Body `Ctrl + I`
• Reference`Ctrl + Q`
• Insert Link`Ctrl + L`
• Inserting code`Ctrl + K`
• Insert Picture`Ctrl + G`
• Promote title`Ctrl + H`
• Ordered list`Ctrl + O`
• Unordered list`Ctrl + U`
• Line`Ctrl + R`
• Revoke`Ctrl + Z`
• Redo`Ctrl + Y`

And find out the maze of HDU 1272 little Nozomi

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.