Sub-tree generation:
When the Minimum Spanning Tree is obtained, the array path [I] [J] is used to represent the maximum edge weight from I to J in the MST.
After the result is obtained, enumerate all edges that are not in the MST and
Find the first in-depth Priority Search question and find the number of eight connected blocks in the figure.
# Include # Include Using namespace STD;# Define x 100Int visit [x] [x];Int A [x] [x];
Void DFS (int x, int y) // deep Priority Search{If
Question:Given n sides, each side has a certain length. Now we need to enclose all sides in a triangle and ask how many different triangles can be formed (the three sides have at least one side ).
Analysis:Number A, B, and C sides of a triangle.
Count color
Time limit:1000 ms
Memory limit:65536 K
Total submissions:16872
Accepted:4839
Description Chosen problem solving and program design as an optional course, you are required to solve
Analysis: Status compression of BFS or DFS status + shortest path.
The former is similar to the method used to save the big soldier Ryan. The latter is very classic. the DFS is arranged in full and enumerated, and then added according to the
/*
Question:
Every cow prefers to produce milk in different places. Each place can accommodate only one cow.
Analysis:
Establish a match between the milk producing place and the cows, and then use Hungry
Question:
The subsequence that calculates the longest weight increase and IQ decrease
Analysis:
It is actually the deformation of the longest ascending sub-sequence. In fact, it is very easy to sort by weight from small to large,
Then it's
Question:Determine whether two phone numbers can constitute a prefix relationshipAnalysis:The dynamic build tree is indeed time limitted. It can only be a static build tree or directly arrange the Lexicographic Order and then compare the adjacent
Question:Returns an interval of Analysis:Double screening, where the number of intervals may be large, so it is obviously not feasible to use Trial Division;First, the prime number from 1 to 47000 is filtered out for the first time.Determine whether
Question:Each time, only one digit can be changed to a new prime number,How many times can be used to change to the second given prime number?Analysis:Since it is classified into BFs, we can use BFs to do it. We can judge a table with a prime number,
Question:Residents on the island need to build the shortest road to minimize costsAnalysis:It is actually the minimum spanning tree. You can use primAlgorithmAnd the Kruskal algorithm,Based on the recently learned Kruskal algorithm, the following is
Longest Common subsequence template of LCS:
The state transition equation isDP [I] [J] = DP [I-1] [J-1] + 1 If (in [I] = target [I])= Max {DP [I-1] [J], DP [I] [J-1]} else;Void lcslength (int m, int N, char * X, char * y, int ** C, int ** B){Int I,
/*
Question:
For a very bare sub-tree question, the Minimum Spanning Tree value must be given first. If there is an output that is not connected-1,
Then we need to output the next small Spanning Tree value.
Analysis:
Select prim or
Loading editor...
/*
Question:
Ask if I can make a profit after a round trip
Analysis:
Whether the directed graph is in a negative ring, because each vertex may have a negative ring,
Directly use flordAlgorithmJust do it.
*/
#
/* After the strongly connected component is found to be reduced to a point, the following Tarjan is used to calculate all points with a given degree of 0.AlgorithmThe first is to use the adjacent linked list of the struct, and the second is to use
6727064
2012-09-09 17:39:14
Accepted
4278
0 ms
212 K
853 B
G ++
If
Code Error. Please note ^ Analysis: It is equivalent to converting decimal to octal...
View code
1 # Include 2 # Include 3 # Include 4
Question:
IfCodeError. Please noteX ^ Z + y ^ Z + XYZ = KK (0 1)
Analysis:
Note that the maximum value of Z is 30 (x = 2)When K = 2, it can be determined by using the full square formula, which can be changed to (x + y) ^ 2 = K.When K> 2,
Question: unappeared substrings
Description
[Note] the subdigit string in this question does not necessarily appear consecutively in the parent digit string. For example, we define 1 3 as string 1 5 3.But 3 5 is not a substring of 1 5 3.All
/*
Question:
When the length, width, and height of a doll are larger than the other, the small one can be put in and asked about
Minimum Number
Analysis:
Find the largest independent set, use the total number of dolls-the maximum
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