[Puzzle + Summary]20150808

Source: Internet
Author: User

1. Preface

Long time did not write the test summary, because there is no test (good sense of nonsense). Today's test of the sparse, or because of the exam when the state is not good, some very stupid way to think, but to write a not skilled what the ghost balance tree. After reading the puzzle, I really feel that there is no difficult knowledge point, all is the foundation. So we have to strengthen some basic things later on.

2, Toy play toys

Approximate test instructions: A chain with a weighted value, is now known where each insertion and its weight, the final chain of the state.

The first thought of writing splay, it is feasible, but not enough to understand, so half a day is not fully written out. It is true that this problem does not need to be used in splay, as the question says:

"Because the test range has been warned not to exceed NOIP, the standard algorithm is not a balanced tree. Although the actual situation is to insert elements into the long chain in chronological order, the chain is constantly changing as the elements are inserted, so there is no good algorithm other than simulation. Therefore, we may as well use the inverse thinking to ponder this question. If the insertion point is reversed, first, for each element I, there must be an empty element before it (that is, the unknown element inserted before it), and for the last inserted element N, its final position must be k[n]+1, and no further movement will occur. K[i]-1 Consider the insertion of the n-1 element, ① if k[n-1]<k[n], then the insertion of the nth element does not affect its final position, so its final position is k[n-1]+1, before satisfying it has k[n-1]-1 empty elements. ② if K[n-1]>=k[n], if it is still to be inserted in k[n-1]+1 position, then the insertion of the nth element to make it before the number of empty elements is k[n-1]-2, less than k[n-1]-1. This causes the number of points inserted before it to be greater than the number of positions that can be provided, and it must be inserted in the position of the previously k[n-1]-1 empty element, that is, k[n-1]+2. Then for each element I before this must be inserted in the position of the k[i]-1 empty element before (of course, that position is also empty), so as long as the number from the beginning, the number to a k[i] empty element position, insert it. The naïve algorithm is n^2, so it can be maintained with a tree-like array, as well as a segment tree. ”

3. Guinness Guinness Record

What a ghost list again, today's painting wind seems to have problems.

[Puzzle + Summary]20150808

Contact Us

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.