Ultra-quicksort
Time Limit: 7000MS
Memory Limit: 65536K
Total Submissions: 67681
Accepted: 25345
DescriptionIn this problem, you has to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping, adjacent sequence elements until the sequence is Sorted in ascending order. For the input sequence
9 1 0 5 4,
Ultra-quicksort produces the output
0 1 4 5 9.
Your tas
A-D-queryTime limit:MS Memory Limit:0KB 64bit IO Format:%lld %llu SubmitStatusPractice Spoj dqueryAppoint Description:System Crawler (2014-12-06)Description
中文版
Vietnamese
Given a sequence of n numbers a1, A2, ..., an and a number of d-queries. A d-query is a pair (I, J) (1≤i≤j≤n). For each d-query (i, J), you had to return the number of distinct elements in the subsequence ai, ai+1, ..., AJ.Input
Line 1:n (1≤n≤30000).
Line 2:N numbers a1, A2, ...,
order. To simplify the problem, K.bro promises that the sequence is a permutation of 1, 2, ..., N.Inputthe first line contains only one integer T (t≤200), which indicates the number of test cases. For each test case, the first line contains an integer N (1≤n≤106).The second line contains N integers ai (1≤ai≤n), denoting the sequence K.bro gives.The sum of N in all test cases would not exceed 3x106.Outputfor each test case, output a single line "Case #x: Y", where x was the case number (starting
map up, the last odd and even separate, add in a tree array, minus in the other inside, and then At the end of the single point of the value of the time is the point of their own relationship to the root node, that is, the value of their own should be added, minus the corresponding other tree should be subtracted from the value, and then the beginning of the node itself has a value not added to the tree array, but also to add the original value, this is the answerAnd then with the line tree to
That day when I was doing a usaco problem, I suddenly used a tree-like array instead of a balance tree.(But it doesn't seem to be the idea I pioneered)(But few people seem to use it)The general approach is to rely on binary + tree array, single operation complexity \ (O (log^2 n) \)Although the complexity is a bit higher than the treap, but the code is short!(But I'm not going to post the code QWQ because I'm lazy)not more than \ (10^5 \) length is ve
A tree-like array is a single point of modification and querying the prefix and data structuresQuery and modify time complexity are log (n)For a tree array we first need to know the concept of lowbit.Lowbit is X x.The popular point is the value of the first 1 from the forward number in a number binary.The exact algorithm is two.One is to modify the function as followsvoid Add (int pos, int w){while (POS {C[pos]+=w;Pos+=lowbit (POS);}}One is the follo
StarsTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 5210 Accepted Submission (s): 2053Problem descriptionastronomers often examine star maps where stars is represented by points on a plane and All star has Cartesian coordinates. The level of a star is a amount of the stars that is not higher and is not the right of the given star. Astronomers want to know the distribution of the levels of the stars.For example, look at the map shown on the a
Quick-Arrange algorithm? Simply put a position and then put a smaller number on the left, than his large number on the right, which is clearly a recursive definition, according to this idea can easily write the fast line of code? Quick Platoon is I learn the ACM road first let me remember the code, the impression is very deep, the previous study is Pascal, write this to write a long string, but because and merge sort is short, also back down. Curious I click on the encyclopedia to see the Python
The subject of the problem: with modified, forced online in reverse orderRewrite one of the previous 3744TLE methods to change some of the preprocessing to a tree-like array have to say the tree array constant or smallG[I][J] (IEQUALS[I][J] Indicates the number of J within the front I block this direct violence can beSMALLER[I][J] represents the number of numbers within the first I block less than or equal to J a second-dimensional tree array of viole
It's almost 12 o'clock, and we've just processed two urgent data.Two kids are asleep, and they're a lot quieter.Lately I've been thinking that working overtime every day shouldn't be the meaning of life--it seems like crap.The meaning of life is to live and better continue.Work hard to keep working overtime in order to get the protection of lifeIt's not scientific to spend most of my time working overtime.1. Take care of your body this is hardware (pe
Title: Returns the number of the largest sub-arrays in a two-dimensional integer array. Requirements: 1 Enter a two-dimensional shaping array with positive numbers in the array and negative values. A 22-D array is connected to the end of the line, like a belt. 3 contiguous one or more integers in an array make up a sub-array, each of which has a and. 4 The maximum value of the and of all sub-arrays is evaluated. Requires a time complexity of O (n). De
For a number in the sequence, it must be exchanged with it before it is larger than it.Behind it is smaller than it must be exchanged with itYou can use a tree-like array to store the number of numbers that are smaller before each number in it.Then (i-1)-total[i] is the number of numbers in front of it that is larger than itThen, after all the numbers are stored in the tree array, use Getsum (Num[i]) to find out the number of smaller numbers in the wh
Test instructionsN points form a tree. gives the root node p and the tree structure information.Outputs the f[i of each point]. F[i]: The number of numbers in all sub-nodes with a number smaller than I in the root of I.0Ideas:Method One: Direct DFS, enter the node x to record the number of smaller than X. When you come out X, record the number of smaller numbers than X. Subtraction is f[x]. Combines a tree-like array.Method Two: Write down the DFS seq
Test instructions: Change the rules of bubble sort, each cycle can bubble up any number, ask at least how many times to cycleIdea: Think about it and know just how many numbers you need to have a smaller number on the right.Just use a tmpmin to record the minimum value of the current right, I use a tree-like array to practice.#include HDU5122 K.bro Sorting (tree-like array)
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=2852Main topic : Operation ①: Put a number in the box. Operation ②: Throw a number away from the box. Operation ③: Query box is greater than a K decimal.Problem Solving Ideas :Since the model is a box, not a sequence, it can be maintained in the order of the tree array + inverse number of ideas.Corresponding tree-like array solution:Put a number$ADD (val,1) $Similar to maintaining the number of rev
Problem DescriptionHow many nondecreasing subsequences can you find in the sequence S = {s1, s2, S3, ....., SN}? For example, we assume this S = {1, 2, 3}, and you can find seven nondecreasing subsequences, {1}, {2}, {3}, {1, 2}, {1, 3 }, {2, 3}, {1, 2, 3}.InputThe input consists of multiple test cases. Each case begins with a line containing a positive an integer n that's the length of the sequence S, the next line contains n integers {s1, s2, S3, ...., sn}, 1 OutputFor each test case, output o
A tree array is a data structure similar to a segment tree, and basically a tree array can do the tree of segments;The tree-like array is an array, in the information record has some characteristics, in order to dynamically find the first n and as an example: You can change an array of an element, to find the first n and;The array tree[i] records the and of a[i-lowbit (i) +1]~a[i], lowbit (i), which represents the minimum binary of I, and the expressi
Topic Links:http://poj.org/problem?id=2299Main topic:Give you a sequence of n integers that can only be exchanged for adjacent numbers and eventually into ascending order, Q: How many interchanges are required at least.Ideas:is to ask the number of times the bubble sort is exchanged. In fact, it is to find the inverse number of the original sequence. It can be done with merge sort, line tree, tree array.But if you do it with a line tree and a tree array, because the number of elements is 500000,
See-----> 791,312,811 in the original. Method 11. Controller layer:The method parameter is as follows, must add "%" +name+ "% "/**@description : Cheng Zhixiang com 2018/1/22 pm 5:15V1.0 */@RestControllerpublic Class Usercontroller { @Autowired private teamrepository teamrepository; @GetMapping ("/findbynamelike") public list2. DAO Layer:Be sure to use the JPA-defined form findby+ parameter name +like (parameter)/** data layer
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.