Noip 2006 solution report

Source: Internet
Author: User

Question 1:

On the Mars planet, every mars person carries a pair of energy necklaces with him. There are n energy beads on the necklace. An energy beads are beads with header and tail tags, which correspond to a positive integer. In addition, for the adjacent two beads, the tail mark of the previous Bead must be equal to the head mark of the next bead. Because only in this way, the two beads can be aggregated into one bead through the suction cup (which is an organ that Mars humans absorb energy, at the same time, it releases the energy that can be absorbed by the suction cup. If the head of the previous energy bead is marked as m, the tail is marked as R, the head of the next energy bead is marked as R, and the tail is marked as N, then, the energy released after aggregation is (in the unit of Mars). The head of the newly generated beads is marked as m, and the tail is marked as N.

When needed, the Mars user uses a suction disc to hold the adjacent two beads and aggregate them to obtain energy until there is only one bead left on the necklace. Obviously, the total energy produced by different aggregation sequences is different. Please design an aggregation sequence to maximize the total energy released by a chain of necklaces.

For example, set the head and tail labels of N = beads ). We use the mark "yellow" to indicate the aggregation operation of the two beads. (J yellow K) indicates the energy released after the aggregation of the J and K beads. Then the energy released after the aggregation of 4th and 1 beads is: (4 Tib 1) = 10*2*3 = 60. The total energy released by this chain of necklaces in an aggregation order of the optimal values is (4 then 1) then 2) then 3) = 10*2*3 + 10*3*5 + 10*5*10 = 710.

Calculates the maximum total energy that can be released by aggregation.

 

 

Problem solving process: 1. the deformation of the stone merge. The processing method can refer to the usaco broken chain method to disconnect the ring into a chain and then copy it again. This is much easier to deal. 2. f [I] [J] indicates the maximum total energy obtained from the merging of J beads starting from the I, and the enumeration center point (the two beads merged last time) can be transferred. 3. easy to make mistakes: do not forget to write F [I + N] [J] = f [I] [J ].

F [I + N] [J] is not available. For example, if n = 4, F [3] [4] requires f [5] [2]. If you forget to write, you can only get 20 points.

 

 

Question 2:

Jin Ming's Budget Scheme is an old question. It is good to transfer the funds in five states. because the money is a multiple of 10, the state will be divided by 10. Otherwise, the space will be insufficient.

 

 

Question 3:

Now we need to use M machines to process N parts, each of which has m processes, each of which is completed on different designated machines. Each process of each workpiece has a specified processing time. Each process of each workpiece is called an operation. We use the Mark J-K to represent an operation, where J is a number from 1 to n and is the workpiece number; K is a number ranging from 1 to M. It is a serial number. For example, 2-4 indicates the operation of 2nd processes for 4th workpieces. In this question, we also give an order for each operation. For example, when n = 3, m = 2, "1---" is a given order, that is to say, first arrange 1st processes for 1st workpieces, then arrange 1st processes for 2nd workpieces, and then arrange 2nd processes for 1st workpieces. On the one hand, each operation must meet the following two constraints. (1) For the same workpiece, each process must be completed before it can begin; (2) at the same time each machine can only process one workpiece at most. On the other hand, you cannot change the working status of the previously scheduled operation when you schedule subsequent operations. Because the same workpiece is arranged in the order of the process, only the workpiece number is given in the original order, and the same order can still be obtained. Therefore, in the input data, we abbreviated the order as "1 1 2 3 3 2 ". Note that the "arrangement order" only requires that each operation be arranged in the given order. Not necessarily the actual operation sequence on each machine. During the specific implementation, it is possible that an operation is completed first than the previous operation. For example, n = 3, m = 2. The known data is as follows:

Workpiece number Machine number/processing time
Process 1 Process 2
1 1/3 2/2
2 1/2 2/5
3 2/2 1/4

The two implementation plans in the "1 1 2 3 3 2" order are correct. However, the total time required is 10 and 12 respectively.

 

When an operation is inserted to an empty file of a machine (the last part of the machine that has not been scheduled can also be regarded as a blank file), the operation can be inserted before, back or center. In order to make the problem simpler, we agree that we should try to insert it in front of the constraints (1) (2. In addition, we also agree that if there are multiple blank files that can be inserted, it will be inserted to the first blank file under the condition that the constraint condition (1) (2) is guaranteed. Therefore, under these conventions, solution 1 in the above example is correct, and solution 2 is incorrect. Obviously, under these conventions, the implementation scheme that matches the given arrangement sequence is unique. Please calculate the total time required for the scheme to complete all tasks.

 

 

Problem solving process:

1. I really don't know what this question is. The algorithm tells you how to simulate it directly. I have to read the questions several times, and it takes only half a day to understand the questions. 2. save the start position and width of each blank file of M machines. You can find the first blank file that meets the requirements and modify the information of each blank block. I use O (N) the time directly moves the array back one bit. If you want to pursue perfection, use the linked list O (1) time, but it is also troublesome to write.

 

Question 4:

Set R to a 2 ^ K hexadecimal number and meet the following conditions: (1) R is at least a 2 ^ K hexadecimal number. (2) As a 2 ^ K hexadecimal number, except for the last digit, each digit of R is strictly smaller than the adjacent one on the right. (3) After converting R to a binary Q, the total number of digits of Q cannot exceed W. Here, the positive integers K (1 ≤ k ≤ 9) and W (k <W ≤ 30000) are given in advance. Q: How many R groups meet the preceding conditions? Let's explain from another angle: Set s to a 01 string with a length of w (that is, string s consists of W "0" or "1 ), S corresponds to Q in the preceding condition (3. Divides s into several k-segment segments from the right. Each segment corresponds to a 2 ^ K number. If s can be divided into at least 2 segments, then the binary number corresponding to s can be converted to the above 2 ^ K hexadecimal number R. For example, set K to 3, w to 7. R is an octal number (2 ^ 3 = 8 ). Because W = 7, the 01 string with a length of 7 is divided into three segments (I .e., 1, 3, and the first segment on the left has only one binary segment ), then the octal values that meet the conditions are: 2 digits: (I .e ,..., The maximum value is 6:1 (67 ). 6 + 5 +... + 1 = 21. 3-digit: The value can only be 1 at a high position. The value of 2nd is (that is, 123,124,125,126,127), and the value of 2nd is ,..., 2nd bits are 6:1 (167 ). 5 + 4 +... + 1 = 15. Therefore, there are 36 R instances meeting the requirements. The answer should not exceed 200


Problem solving process:

Think of two methods, but the second one is easier to write. First, analyze the data range, W <= 30000, k <= 9, r maximum length is 2 ^ 9-1 = 511, so W maximum is 511*9 = 4500, therefore, the maximum length of W is about 4500. If the length is larger, the length of the excess value can only be 0.
Method 1 (Dynamic Planning): F [I] [J] indicates the number of incremental sequences starting with numbers not smaller than I and with a length of J. (All numbers are 1 ~ 2 ^ k-1 ). State transition equation: F [I] [J] = f [I + 1] [J] (I headers are not required) + F [I + 1] [J-1] (with I headers); in particular, when I + J = 2 ^ K f = 1; when j = 1, F = 2 ^ k-I; 1. I, J can reach a maximum of 511, and then save a 200-bit high-precision number, A total of 500*500*200 + = 5000 W, the space is obviously not enough, but the data seems not so disgusting, it seems to be enough to save 100-bit high-precision numbers .. The positive solution is to use a rolling array. 2. How can I solve the problem based on the F array? There are two cases. P = W/K, q = 2 ^ K-1, M = w % K, c = 2 ^ s-1;. when converting to a binary system, in addition to P segments, there are M 0 or 1 in front, that is, the leftmost bits of R (2 ^ K hexadecimal) is 1 ~ In C, there are sum (F [s] [p + 1]) conditions. B. when R has a maximum of P segments, the number of enumerated segments is S. The answer is sum (F [1] [s]). When combined, the answer is used to scroll the array, because j = p + 1 is fixed, so let J roll up and use. That is to say, F [I] is used to represent f [I] [p + 1]. At the beginning, I was dumb because when I tried B, sum (F [1] [s]) cannot be obtained .. Dizzy, after a sleep, I went to the second method to write .. This is also the case when the second method is used to write the results. (I do not have a deep understanding of the scrolling array .), Thought of the solution. In fact, when DP is used, it is okay to save all f [1] [J] With an array.
Method 2 (combined mathematics): the method for determining the number of combinations is not mentioned. The key is how to use the number of combinations to obtain ans. The situation is also the same as the above two types of AB. A. For example, if the leftmost is 2, there is P on the right, that is, 3 ~ Q to take the number of P in an increasing queue, that is, in the number of q-2 to take the number of P, the number of the solution is C (q-2, P); so the number of the leftmost enumeration is good. B. It is also the number of enumeration segments S. The answer is to take the number of S in the number of Q, that is, C (Q, S );
It is not difficult to think about algorithms. What is difficult is high-precision processing and optimization of scrolling arrays. In addition, when outputting answers with high precision, if the answer is 0, do not forget the output, because generally, Pos = 200, while (A [POS] = 0) pos --, if it is all 0, no output will be made.

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.