I'm bored with it ..
In fact, the key to this question is not the method of reverse order, because it is also possible to use brute force.
To give a sequence with the length of n (n
I use array a [0 ~ N-1] to store raw data. You only need to find the sum of the reverse order of the original sequence, and then for each order of a [I] (0
1. Violence Law.
together, output the method in the following fomat:
I1J1I1J1 ......
WhereIk Ik(K> = 1) are the identification numbers of the two computers to be connected. all the integers must be separated by a space and there must be no extra space at the end of the line. if there are multiple solutions, outputLexicographically smallestOne (see hints for the definition"Lexicography small") If you cannot connect them, just output"-1 "in the line.
Sample Input
230 2 32 0 53 5 020 00 0
Sample outpu
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1394Understand the merger sort, learn a bit of other people's blog, have the topic to knock over ...This problem I use merge sort is I currently the fastest algorithm 62ms ... Of course, in my blog There are also wired and tree arrays to find the reverse number of the template;Here I do not discretization, but not all the reverse number of templates ...I recommend a blog with a very detailed illustration of what I don't know about merge sort;
Say nothing, directly on the code.The first is the node class, we all know/** * Binary tree node class * * @author heyufan * * @param And then the implementation of the two-fork search tree. /** * */package datastructure.tree.binarytree;import java.util.linkedlist;import java.util.Queue;/** * binary sorting tree * * @author Heyufan * */public class binarytree Test:/** * */package datastructure.test;import datastructure.tree.binarytree.binarytree;/** * @author Administrator * */public cl
function Node (data,left,right) {this.left=left this.right=right this.data=data} function Btr () {this.root = null; }//D: Root node L: Left Dial hand node R: Right child node btr.prototype.insert=function (data) {//Generate sorted two fork tree if (this.root==null) { This.root = new Node (data,null,null)}else {var current = This.root; while (true) {if (dataJS two fork tree, pre/middle order/Post
|Submit | BackFirst Baidu reverse order number:in one arrangement, if the front and back positions of a pair of numbers are opposite to the size order, that is, the preceding number is greater than the subsequent number, then they are called aReverse. The total number of reverse order in a permutation is called this permutation.number of reverse
=1394Title: To a group of numbers, each time you can get the beginning of the number to the end, ask such a sequence of the number of reverse order of the smallest inverse valueTitle Analysis: First Use the tree-like array to reverse the number, the reverse value after each Exchange can be directly calculated, because it is a 0~n-1 arrangement, so the first number (set to FIR) to the last to reduce the number of FIR in reverse
Question: Click to open the link
ThemeReturns the longest return string of a string. If multiple results exist, the minimum Lexicographic Order is output.
IdeasWe all know that we can calculate the maximum length of a string in the descending order of a string and the longest common subsequence of the original string.However, this question should not only be ou
never happen on S or T.InputThe first line of the input contains three integers n (2You can assume that number of 1s would not exceed for the input.OutputIf There is no-lose touch with B, print "No answer!" Otherwise, the first line contains a single number T, which was the minimal number you had got, and if T is not zero, the Second line was needed, which contains t integers in ascending order that indicate the number of people who meet bad things .
Minimum Inversion numberTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 14879 Accepted Submission (s): 9082Problem DescriptionThe Inversion number of a given number sequence A1, A2, ..., the number of pairs (AI, aj) that SA Tisfy i For a given sequence of numbers a1, A2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we'll Obtain another sequence. There is totally n such seq
-- 2 to --- 5 to 2. Then 1, calculate the 2--5 range and 2, and then update 1 to -- 2 to --- 5 to 3. Then, 5, calculate the 5---5 range and 0, and then update the 5 range to -- 5 to -- 5 to 4. Then 3, calculate the 4--5 range and 2. Then add all the sums 1 + 2 + 2 = 5, that is, the number of Reverse Order pairs, the simplest line segment tree application. For the current question, the array is required to be circular. You can start from any po
search, the reverse order ensures the minimum Lexicographic Order,
Therefore, in the reverse direction, it will first expand to AAA and find the solution.
Break is obviously faulty,
Obviously, this Lexicographic Order is not necessarily the smallest, and the results of the first half are not taken into account. So we
, but the mark in the last update is complete,, first of all the number of inputs before it is larger than its number (that is, see this number to n-1 a total of several appear in the previous input, , that is, to look at the Mark's and),, that is, the inverse sequence of it, and then add (mark) it to this tree (update), and, as you can see, if you change the tag to hold this number, and wonder if the tree's leaf node is a sort of 1~n-1 sequence,,, this section of the picture is good understandi
A ring string is output to obtain the minimum Lexicographic Order of the string clockwise starting from a certain position.
Directly simulate moving one character to compare the Lexicographic Order at a time. Note that there cannot be overlapping parts in the strcpy (S + 1, S) Post-shifting strcpy replication address.
#include
Some DNA sequences exist in Circ
The main effect of the topic
Gives a string that outputs its longest palindrome string, and if there are multiple results, the output dictionary order is minimal.
Ideas
We all know that after a string is in reverse order and the original string into the longest common subsequence, you can calculate its longest palindrome string length.
But this problem is not only to output palindrome string, but also r
Determine the position of the matchTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 33964 Accepted Submission (s): 13321Problem DescriptionThere are N teams (1InputThe input has several groups, the first behavior in each group is two number n (1OutputGive a ranking that meets the requirements. There is a space between the queue numbers at the time of the output, and no space after the last.Other Notes: Qualifying rankings may not be unique, at w
smallest number of reverse order is how manyExercisesAh, the largest number is N, the first number is thrown to the end, then the number of reverse order reduced num[i]-1, but increased the n-num[i], then just do it!Code://Qscqesze#include #include#include#include#include#include#includeSet>#include#include#include#include#include#includetypedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);
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.