Multi-school question

Source: Internet
Author: User
Tags rounds
Here, ZCCLovesInterdivZCCLovesCOT first considers the version in one dimension. The line segment tree can be used, but it is difficult to extend the line segment tree to a high dimension. In view of the features of this question, we can only save the array after the difference. Search for the prefix and restore the original sequence before processing the query.

Here, ZCC Loves Interp ZCC Loves COT first considers the version in one dimension. The line segment tree can be used, but it is difficult to extend the line segment tree to a high dimension. In view of the features of this question, we can only save the array after the difference. Search for the prefix and restore the original sequence before processing the query.

Question

ZCCLovesInterp






ZCCLovesCOT

First, consider the version in one dimension. (Series, range addition, range and)

It is obvious that you can use a line segment tree, but it is difficult to extend a line segment tree to a high dimension.

In view of the features of this question, we can only save the array after the difference.

Calculate the prefix and restore the original sequence before processing the query. After that, you can obtain the prefix and O (1) to answer the question.

Now I am trying to extend it to two-dimensional. (Triangle, subtriangle plus, subtriangle and)

If you simply apply a one-dimensional Difference Method to each row, the final mark will be as follows:


The + 1 mark and-1 mark are consecutive segments.

Tag is also a value, so you can mark it!

So we divide all the + 1 tags from top right to bottom left, and divide all the-1 tags from top left to bottom right.

In this way, each operation only needs to modify four values in two arrays, and then use these two arrays to restore the original tag and use the marker to restore the original number array. The Calculation of prefix and is similar, but the prefix of the second dimension must be calculated separately from the two directions.

Similarly, only four arrays are required to represent all the tags in three dimensions. After three rounds of search for the prefixes and operators in different directions, we can obtain the original operators, the calculation of the prefix and also requires four arrays. In this way, 8 single operations/single queries are split into O (1), and the complexity is O (N ^ 3 + M + Q ).


ZCCLovesRPG

There are several bars in each position of the program, such as a [x]> = v or! (A [x]> = v. They determine an upper bound and a lower bound for each a [I. Obviously, we should make a [I] as small as possible, so we can make a [I] Just get its lower bound.

So, consider the Ui of a series of upper and lower bounds,Di. The condition that the current statement can be executed is:

As the process of analyzing the program changes, the lower bound of some locations, we need to recalculate the maximum non-zero sub-segment sum at any time. That is to say, we need to support single-point modification for a series and query a maximum of non-zero sub-segment and. This is a classic application of a line segment tree.

The following describes how to analyze programs.

First, you need to implement a lexical analyzer: it accepts a string as its input and returns a mark (constant, symbol, or identifier) each time ). This part can be written according to the write read optimization method.

Then the process of analyzing the mark stream is completed. There are many practices in this step. Here we will only talk about the std practices.

First, set game (n,K) read, get n,K value, and create a line segment tree.

Empty two stacks. One is used to save the program structure (called Stack P), and the other is used to save the changes in the Ui and Di for easy undo (called Stack Q ).

Read the left curly braces and press a B symbol into Stack P. The B Symbol declares that the current statement is in a pair of unclosed curly braces. When the top of stack P is the B symbol, you can append a statement to the curly braces.

Then repeat the following process until the stack P is empty.

Check the stack top of stack P:

If it is B:Obtain the next mark from the lexical analyzer.

If it is right curly braces, B is displayed. (Closed curly braces)

Otherwise, push the mark back to stack P to the S symbol. (Append Statement)

If it is S:Pop up S to get the next mark from the lexical analyzer.

If left curly braces: press the B symbol into Stack P. (New block)

If it is cg: Read the entire cg statement, query whether the current is reachable, and update the answer.

If it is if: read the first sentence of the if statement, read x,V. Press I, T, and S into Stack P successively. Pushed to stack Q successively! (A [x]> = v) and a [x]> = v. modify a [x]> = v on the online segment tree.

If it is T:Pop up T, pop up the top element of stack Q, and undo its modification. Obtain the next mark from the lexical analyzer:

If it is else: The top element of the Q stack of the Application Stack (previously added but no application! (A [x]> = v. Press the S symbol into Stack P.

Otherwise, put the mark back. The top element of stack Q stack is displayed, and the top element of stack P stack is displayed (it must be an I symbol ).

If it is I:Pop up I, pop up the top element of stack Q, and undo its modification.

The four symbols B, S, T, I mean: Block, statement, and Then end, and the entire If end.

Finally, output the answer.


ZCCLovesMinecraft

The desired S is the orthogonal convex hull of the current point set.

See the Introduction of en.wikipedia.org/wiki/orthogonal_convex_hull. Intuitively, the orthogonal convex hull is a polygon consisting of four broken lines in the upper left, upper right, lower left, and lower right. Each side is parallel to the coordinate axis. To obtain the orthogonal convex hull of a known point set, you can first find the top, bottom, left, and rightmost points. Find a line in the upper-right corner. You can start from the top point. Each time you find the top point on the right of the current point, connect it to the current point in the L-shape, and use it as the new current point, repeat until you select the rightmost vertex. The implementation of this process is very simple, as long as you first sort by abscissa, then scan it again and maintain the maximum ordinate value. The method for the other three segments is similar and can be converted by rotation. For the dynamic addition problem, you can use four balance trees (to implement STL) to maintain four broken lines respectively. When the line is inserted, try to insert it into the corresponding positions of the four line segments. If the line is to be updated outside the current line, and calculate the increment of the area. Taking the upper-right line as an example, you need to constantly determine whether the point on the left of the new point is below the new point. If so, delete it. Since each vertex can be inserted and deleted at most once, the total time complexity is O (nlogn ). The boundary condition requires a certain level of special judgment.


ZCCLovesWords

We can create an AC automatic machine for words first. Then count (dp) on the AC automatic machine ). F [I] [j] indicates the I-bit of the current length and the j-node of the current AC automatic machine. We want to take the initiative to transfer. If node j reaches the k node after receiving the character "c, then F [I + 1] [k] + = F [I] [j] * Get. Get indicates the number that can be multiplied by the k-th node.

Let's analyze Get ., If there is no such thing as + I, we can create a matrix and then directly multiply the power + matrix. But with + I, each matrix is different, but in fact P = 179*173*163, where the prime number is very small, and then it is a messy part. IModPi is the cycle of O (Pi), so we create a Pi matrix, and then perform the rapid power + matrix multiplication for the L/Pi part.ModPartial brute force matrix multiplication of Pi. The Chinese Remainder theorem can be used to calculate the final answer for the answer obtained by each prime number. The complexity is roughly O (Pi * tot ^ 3+Log (L) * tot ^ 3 ).

If you have better practices, please feel free to advise.



ZCCLovesCards



ZCCLoveRanklist

Question 1:

When k = 1, the answer is obviously n-1.

When k = 2 t (t ε Z *), the answer is obviously 0. Divide the game into two groups. Each group is n + 1.

When k = 2 t + 1 (t ε Z *), there are only three groups in two. When n is an even number, the answer is obviously not 0, but 1. This can be done if the number is odd. One solution is:

N is an odd number.

1

4

7

N is an even number.

1

4

6

2

5

5

2

5

4

3

6

3

3

6

2

4

7

1

4

1

5

5

1

6

5

2

3

6

2

4

6

3

1

7

3

2

Second question:

First, observe the nature of the progress index: Because NewRank = OldRank, the Progress Index = 0, so it can only appear once, so it should not be used. When NewRank! = When OldRank, the two Progress indexes are equal. If NewRank and OldRank are both equal, the two Progress indexes are the opposite. If NewRank1 = OldRank2 and OldRank1 = NewRank2.

A total of n * (n-1) + 1 different progress indexes, and n> 1, so each progress index (except 0) will appear. In addition, a pair of opposite numbers of the Progress index can only appear in the same test. Therefore, when n is an odd number, there is obviously no solution.

When n is an even number, it is noted that each test is actually to team up candidates for n-1 rounds without repeating. So we can use round robin to construct an algorithm.

Round Robin Construction Algorithm: http://www.doc88.com/p-694165485213.html



ZCCLoveMarch

We use set to maintain the current location of the soldiers. When the merger is performed, each soldier is forcibly merged to this location, that is, the former soldier is deleted and the target location size + = the original location size. The size of the original position is changed each time you move the task, and a new soldier with a size of 1 is created in the new position. In this way, only n + mobile numbers are allowed.So the time complexity is O (nlogn ). To record the coordinates of each point, you can use and query the block where the set is maintained.


ZCCLoveTrafficLights

First, consider how to create a general graph. It can be proved that there is an optimal solution stuck with time on a certain side or stuck with time. If this is not the case, you can push the time of each point back until the time is stuck. Therefore, you only need to determine the card situation at each point.

After enumerating the arrival time of a certain point, we can use the shortest path algorithm to find the earliest time to the end point and the latest time to start from the start point. In specific implementation, you can enable eight status records for each vertex to indicate the direction in which the traffic enters and whether the traffic passes through the red light.


ZCCLovesArmy

Solution:

We can find that the relationship between superiors and subordinates can constitute a tree and consider three operations.

Exchange subordinates: to reduce the number of sides changed during the exchange of subordinates, you can use the left son and right brother to represent the tree. Therefore, you only need to change up to four sides when switching. LCT can be used for maintenance.

Transmit information: calculates the minimum number of intermediaries required to transmit information from x to y. Make x a point with a large depth. This path is x uploaded to the same layer as y and then horizontally transmitted. You can assign the weight of the son numbered 1 to 1, and calculate the sum of the weights on the simple paths x and y.

Send command: Ask x to receive commands from several soldiers. The result is displayed in the tree of the Left son and right brother, that is, the number of vertices between the vertex and the root.

Postscript:

For convenience, you can add a virtual child numbered 0 to each vertex to avoid some details.

When you exchange subordinates, you can open a Balance Tree for each vertex, or use the Splay in LCT.


ZCCLovesCodefires

Evaluate the knowledge of the adjacent question I,J (I in front ). After they are exchanged, the contribution of the time brought about by their previous questions to the answers remains unchanged, and their contributions to the subsequent questions remain unchanged, the contribution of other questions to the answer will naturally remain unchanged. The only change is that the original EiKj item is changed to EjKi. Therefore, to optimize the answer, the condition that must be met is EjKi ≤ EiKj. That is, Ei/Ki ≥ J/Kj.

Then, the optimal sequence Ai must satisfy, and EAi/KAi is increasing progressively.

Sort it once.

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.