Noip 2015 brief _noip

Source: Internet
Author: User

And finally, a nice soy sauce.

[Day 1]

T1 Magical Magic Square

Send a simulation problem, but met a very abuse of the younger brother:

/************************************* above Pure entertainment cut ********************************************/

T2 Information Transmission

In a graph with only n-direction edges, each node is given a degree of 1, and a ring with the least number of nodes is obtained.

Analysis: Because there are only n edges and each point has and only one side to go out, so there may only be a simple ring, do not appear that 8-shaped ring ring.

Proof: Each point has two kinds of conditions: 1. No such point in any ring can be directly ignored, as there are n-1 points, n-1 side to prove the line. 2. In a ring. So if we now have a circle-shaped ring, the size of K, then each point should be in the degree of 1, such a loop only exists a loop, that is, a simple ring, if there are multiple loops, then there should be a point of the >1, but also to ensure that the other point out of at least 1, So the sum of the degrees should be >k, but the degree of =k and is not satisfied, so there is no loop with two or more of the number of loops. Certificate of Completion.

By satisfying this nature, Tarjan or O (n) scans can solve the problem.

T3 the Landlord

With some hn, ZJ in the online discussion, think this topic as the third problem, not reflect the due value, just let a lot of people spend a lot of time on it, and the first topic description has not clear, and the data pure random also let people very not taste, After all, perhaps some people with search pruning happen to get high points and even AC, and those who write a good standard algorithm is stuck, oi after all is not a contest of luck, but the power of contention.

Because before the simulation game, I wrote a pressure DP space, then this problem space 1G too dazzling, coupled with the complex NP problem and a relatively small range of data, in the examination room on the direction of the pressure DP to think, first for each hand, we preprocess each possible way out of the card, and throw it into an array, and in the DP, record a CNT represents the current number of cards, with Bool[i] (i is binary) to represent the CNT secondary card, the state I can be achieved, and then as long as a meeting 2^m-1 is all cards out of the situation can be achieved when the exit, At this time the CNT is the least number of cards.

The specific time complexity varies according to each deck, but should be over 60% of the data is no problem.

After the match: Get the program to write after writing, the DP is really able to over 60% points, but if you want to AC words or to use the dfs+-like pressure DP or a direct *.

[Day 2]

T1 Jump Stone

It's easy to think of a two-point answer to the question of the maximum or minimum value.
Specify: We already know the answer is K, that is to meet the minimum distance max for K, then the final removal of stones after any two of the distance between the stone is greater than or equal to K, then we only test whether can move m block stone to meet K on it.
First of all, the title tells us that the beginning of the stone is 0 is fixed, and then if we move a stone I, if the left side of the stone has met the answer K, then remove I to the answer is not affected, because to the left of the stone distance will only become larger, not less than K.
For the current stone I, the next stone is j,pre[i] for I on a stone, Sub[j] for J under a stone


There are two possible ways:
The distance between 1.i and J is less than or equal to K, which is not satisfying the answer, so what we have to do is remove J.
Because I to pre[i] is >=k, then J to Pre[i] must also >=k, but I do not necessarily satisfy I to sub[j the distance >=k, let alone from the Sub[j] more near J, so for the later stone consideration, we need to remove J.
The distance between 2.i and J is greater than K, that is, the i,j is already in line with the condition, then nothing can move.
Since I to j the distance is greater than K, so for J after each stone, are satisfied with the condition, so I have no effect on the test answer, how to consider it. J will then become the next I, as in the case of two different cases dealt with.
So the concrete is the two-point answer K, then O (n) test, the total complexity O (NLOGL).

PS: There is a special situation to consider, that is, n can equal to 0, this time the answer is directly l, but the processing method is very simple, two points to the upper bound to the L, so there will be no impact.

T2 substring

The main idea: to choose the B-string to select the K-section, combined in order to form a series of the number of schemes.

The stage of the subject is very clear, f[i][j][t] means that when the a,b match to the I,J bit, the number of schemes for the T substring of B has been used, and match[i][j] represents the maximum number of digits, such as a,b, that can be matched forward when the i,j match to the A=cabab,b=cab bit respectively. Then Match[5][3]=2,match can be violently preprocessed.

Considering the case of the I-bit mismatch and the maximum forward matching match[i][j] position, the transfer equation is derived:


But obviously such complexity is in the worst case O (n*m^2*k), so we have to consider optimization.

The first is space: The n*m*k can reach 4kw, obviously not enough, and then we found that the number of alternatives to the T-string is only related to the number of scenarios selected for the t-1 substring, so we consider using time to change space, using a scrolling array, f[0] and f[1] Two two-dimensional arrays to solve space problems.

Then it's time: look at the transfer equation, which is actually a summation, so what exactly is it? If we think of f[i][j] as a two-dimensional matrix, we are actually seeking to i-1,j-1 the element on the main diagonal of the square in the upper-left corner (because each substring cannot be empty so that at least one) is the lower-right corner, the i-match[i][j],j-match[i][j] , so for this sum, we can consider using a similar prefix and method O (1) transfer, another open array g[i][j] representing the sum of the elements on the entire slash in the lower-right corner of the i,j, then the transfer equation is updated to:

This will reduce the time of an O (M), but because of the use of a scrolling array and the constant is a bit large, it is important to pay attention to some minor optimizations in the actual enumeration to eliminate some unnecessary states.

T3 Transport Plan

In the examination room did not do it, knocking a 50 of the simple, and then consulted the Wzy and ZK, too powerful.

The general framework is a two-point answer and tested by LCA.

But there are a few points to note:

1. Two points when the Wzy is a direct two-point path total length, ZK is a two-point selection as the length of the edge of the wormhole, so the gap is about a log level of complexity, but the actual effect is the same, this is worth learning.

2. If the LCA is to be hung with ordinary multiplication, use Tarjan off-line to ask for LCA.

3. What has not been resolved: we can use some special techniques when doing the path processing, give each point a weight value, in the LCA time incidentally processing, then can get each edge by how many paths covered, convenient to check the answer.

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.