Hdoj 1116 Play on Words [merge query set] + [Euler's path], hdoj Euler's path
Play on WordsTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 5622 Accepted Submission (s): 1850
Problem DescriptionSome of the secret doors contain a very interesting word puzzle. the team of archaeologists has to solve it to open
];//whether the mark Point existsint inch[MAXN], out[MAXN];//in degrees, out ofintDIFF[MAXN];//the point at which the degree of entry is not equal to the degreeintSet_find (intd) { if(fa[d]0)returnD; returnfa[d]=Set_find (Fa[d]);}voidSet_join (intXinty) {x=set_find (x); Y=Set_find (y); if(x!=y) fa[x]=y;}intMain () {intT,n,i; Charword[1024x768];//Word intb;//first letter, tail letter intRoot//number of root nodes intM//The number of points that are not equal to the out degreescanf"%d"
1. Test instructions: give n words and ask if you can concatenate all the words in the same way as the idiom solitaire.2. Idea: The word is viewed from the initial letter to the tail letter of the Forward Edge (ARC) can be. As long as the graph is Eulerian graph, then it can be connected. Otherwise, you cannot do so. when writing and checking the Union, be careful to note that it is a=find (a); Don't repeat
Play on words
Some of the secret doors contain a very interesting word puzzle. the team of archaeologists has to solve it to open that doors. because there is no other way to open the doors, the puzzle is very important for us.
There is a large number of magnetic plates on every door. every plate has one word written on it. the plates must be arranged into a sequence in such a way that every word begins wit
Question:
There are n words separated by lowercase letters. It is required to determine whether there are two adjacent words in a certain arrangement. The last letter of the first word is the same as the first letter of the last word.
Analysis:
When two letters of a word are considered as nodes, a word can be considered as a directed edge. The arrangement in the question is equivalent to the existence of Eu
= Find (x), FY =Find (y); if(FX! = FY) Pre[fx] =fy; }BOOLisconnct ()//Determine whether the graph is connected, that is, all the points are in a set {intCNT =0; for(inti =1; I if((outdegree[i]! =0|| Indegree[i]! =0) Pre[i] = = i) cnt++; if(CNT = =1)return true; return false;}BOOLIseulur ()//whether there is Euler pathway {intCNT =0; intFlag =0; for(inti =1; I -; i++) if((outdegree[i]! =0|| Indegree[i]! =0) (indegree[i]! =Outdegree[i])) Judging the singularity, the method is n
Build edges by letter, with the first and trailing letters of each word plus edges. First of all to determine whether connectivity, and then determine the degree of each letter and the degree of the difference in the absolute value is greater than 2, and then the degree and the difference in the absolute values of 1 can not exceed two. You can form Euler's path.The code is as follows:#include HDU 1116 POJ 1386 Play on
Tags: blog HTTP Io OS AR for strong SP Div
Problem address: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1116
A question about Euler's loop. I have just been in contact with oocl, so I have collected some information:
Definition of European Union:If such a path exists in graph G so that it passes through every edge of graph G once, the path is called
Euler's path. If the path is a circle, it is called
Euler's (Euler) loop. An image with an Euler's path is called a map E ).
Methods to determi
Question link:
Http://poj.org/problem? Id = 1386
Play on words
Time limit:1000 ms
Memory limit:10000 K
Total submissions:9685
Accepted:3344
DescriptionSome of the secret doors contain a very interesting word puzzle. the team of archaeologists has to solve it to open that doors. because there is no other wa
Transmission DoorWords1-play on Words#graph-theory #euler-circuitSome of the secret doors contain a very interesting word puzzle. The team of archaeologists have to solve it to open that doors. Because There is no other-a-to-open the doors, the puzzle is very important for us.There is a large number of magnetic plates on every door. Every plate have one word written on it. The plates must be arranged to a s
HDU1116 Play on Words [European Union] + [query set], hdu1116 European Union
Play on WordsTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 5736 Accepted Submission (s): 1897
Problem DescriptionSome of the secret doors contain a very interesting word puzzle. the team of archaeologists has to solve it to open
word is equal to the last letter of the previous word. all the plates from the list must be used, each exactly once. the words mentioned several times must be used that number of times.If there exists such an ordering of plates, your program shocould print the sentence "ordering is possible.". Otherwise, output the sentence "The door cannot be opened .".
Sample Input32ACMIBM3ACMMalformMouse2OKOK
Sample outputThe door cannot be opened.Ordering is poss
Play on wordsA question on the Purple book:Enter n (nAnalysis:Consider the letter as a knot, the word as a forward edge, then the problem has a solution, when and only if there is Ouratonlo/Euler circuit in the diagramOuratonlo/Loop: A path/loop that passes all the edges once and only once across all vertices in the diagramThere is a criterion for the existence of a Euler loop in a direction diagram: When and only if the graph is strongly connected an
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.