This is the Medium-Hard side, the creator of BDHIJL.
Part of my fault for the wrong schedule for question C. Originally, this was a simpler geometry problem, but in order to balance the difficulty, the meaning of the problem was slightly modified. It is not correct to apply the correct method of the original question to this question (if it is greater than180^\circwhen). It is true that the questioning process is not standardized, and there is no good verification method. On the other hand, shortage of manpower (almost only two available labor qwq) is also one of the objective reasons.
My apologies to all contestants affected by Question C.
These questions are some interesting ideas I have accumulated over the past few months. In addition to the two temporarily added code questions, the remaining few questions are still very interesting qwq, but it is really difficult to put them in the CCPC sub-station, and the discrimination is not as good as expected.
Now this set of questions (except C) has been uploaded to Gym, and you can VP or submit questions on it. Hope to continue to play the value of these topics.
Below I will add more detailed solutions to these questions, as well as some of my views. Teams with training needs please do not check the solutions below.
B. Bounding Wall
A well-regulated data structure question.
First find that we can\mathcal{O}(n+m)Quickly maintains the length of white space that each square extends up/down/left/right. Suppose the currently queried block(i,j)On the lower boundary, we enumerate the points corresponding to the upper boundary(k,j)\ (k \le i). We also need a vertical border. We can find that the left and right sides are independent, and we can handle them separately. according tokenumeration in descending order, starting with(i,p)The vertical border extending upward will disappear at some point. At the same time the firstiline and numberkThe line also has the most extended length, so it becomes a vertical border asking if the prefix/suffix still exists. Binary using tree arrays\mathcal{O}((n+m)q\log(n+m))You can pass this question. The standard calculation uses the union search to point to the nearest survival point, and the time complexity is\mathcal{O}((n+m)q\alpha(n+m)).
D. Defend City
My favorite question, maybe I will never be able to come up with such a good question in my lifetime. The meaning of the question itself is very simple: there are four kinds of points in the plane covering a certain direction1/4Plane, ask how many points can cover the entire plane at least.
All four directions require at least one point, and we record the point sets in the four directions asP_1,P_2,P_3,P_4. For each point set, obviously only the points that are not covered by other points in the point set need to be left, and the remaining pointsywithxincreases and changes monotonically. Let each direction choose a subset Q_i\subseteq P_i. AssumeQ_iThe combined coverage area isS_i,AssumeP_iThe combined coverage area isT_i.
Conclusion: There exists an optimal solution such that|Q_1|=|Q_3|=1or|Q_2|=|Q_4|=1.
Consider an optimal solution, assumingQ_1\ge 2, any pair of adjacent pointsp,q, observe the intersection of their covered areasr. ifrquiltQ_2orQ_4Points in the coverage, obviouslyQ_1Deleting a point in can still cover the entire plane, contradicting the premise. SoQ_1The intersection of all coverage areas inr_ican only beQ_3point coverage in . in turn,Q_3withQ_1the same way. consider laterQ_1,Q_3The intersection point of the leftmost coverage area can cover allQ_2The area that needs to be covered, that is,Q_2,Q_4There is only one point.
Next may wish to make|Q_2|=|Q_4| = 1,at this timeS_1andS_3The intersection point of the contour lines to fall intoT_2andT_4among, andS_3Contours are always onS_1Right and above the outline.
May wish to enumerateQ_1The top point, we can greedily take the bestQ_3The topmost point, the successor, is unique. sameQ_3A point in also has a unique successor. Keep choosing the only successor until theT_4There is an intersection in .
Using doubling , one can do\mathcal{O}(n \log n)time complexity.
We can prove that when the answer\ge 5, the optimal solutionQ_1top pointp_konly one. which isT_1andT_2Contour intersection point, the point on the left or below (according to the direction of intersection).
forP_1middleybigger pointp_t, obviously the newly added coverage area isp_kSubsets of new coverage areas are added. forysmaller pointp_t, will make the corresponding inP_3successor inp_sworse. afterp_sexistP_1The successor inp_kNothing to do.
find this pointp_kcan directly\mathcal{O}(n)simulated.
H. Holy Sequence
Examines familiarity with counting DPs and use of combined meaning.
Consider the DP equation for Stirling numbers of the second kind:s[i][j]=s[i-1][j-1]+s[i-1][j]*j, to find a combination meaning for it. if transferred ass[i-1][j-1], indicating that a new numberj+1. if transferred ass[i-1][j]*jIndicates adding a[1,j]number inx. It can be found that any legal sequence is counted exactly once.
The transfer of DP is a DAG, then DP can be regarded as the path count of DAG, and the legal sequence and slave(0,0)arrive(n,j)The paths correspond one-to-one. Transfer edges are divided into two categories, which are marked here with different colors.
hypothetical figuresk appears in the legal sequencextimes, contributed tox^2. Combination meanings can be considered, expressed inxindivualkThe number of options selected twice in . There are two types of situations: the same position is selected twice, or different positions are selected. Here we only consider how to deal with choosing two different locations.
Different transfer edges correspond to different decisions (what number to put in which position). Since a certain number must not be the maximum value of the prefix after it appears for the second time , it can only be a yellow transfer edge.
In one case, as shown in the figure above, it is necessary to find the number of paths passing through these two transfer edges. Can go from left to right D(0,0)Number of paths to the brown point, right to left DP(n,j)to the number of purple points (additional state: whether a transfer edge is selected).
Another case is that the transfer edge on the left is a yellow transfer edge. This would make a prefixedkTo make a contribution, just make a difference. The time complexity is\mathcal{O}(n^2).
I. Interstellar Hunter
Comprehensive examination of basic linear algebra and number theory knowledge.
It can be proved that at any time, the reachable point set can be represented by two basis vectors . Represent the basis vectors in canonical form: one of the vectors(d,0)\ (d \ge 0), another vector(x,y) \ (x < d, y \ge 0). This can quickly merge after adding vectors.
Let the added vector be(a,b), we can use(a,b)with(x,y) Linear combination out(d',0), then the newdthat is\gcd(d,d') up. empathy newyfor\gcd(b,y)(vector(d,0)will not contribute in this direction), use extended Euclidean to find the coefficients, and calculate the newx.
special attentiond,x,yfor0Case. The time complexity is\mathcal{O}(n \log(x+y)).
J. Jewel Splitting
Various tricks for hashing…
for eachd, happens to have n/dsubsections: prefix + suffix. Calculate the hash values of all prefix subsections and suffix subsections, and discretize them (in order to maintain the hash values of the collection, convert them into sequence hashes). The enumeration prefix can dynamically maintain the number of occurrences of each sub-segment. In order to deduplicate, it is also necessary to maintain the hash value of the collection. Using a hash table to maintain a better time complexity requires writing a total of four different hashes. The time complexity isO(n \log n).
L. Lost Temple
Unexpectedly, no team passed this question qwq This is a question that requires imagination owo
The key property of this question is: the difference between the answers of two adjacent columns is at most1. Determine whether a column can be inxDisappear after a year? Findings can be translated into whether theiThe scale under the column isxrhombus. It will be constrained by four directions and can be transformed into a four-time RMQ problem.
Since the answers in two adjacent columns differ by at most1, we can brute force enumerate the answers based on the previous column. At the same time, it is found that the interval of RMQ query is roughly monotonous, and monotonic queue maintenance can be used, and scattered segment violence (length at most2). Implementation still requires some superb skills, and at the same time maintain4monotonic queue and8pointer.
I'm about to retire, and I always wanted to make some small contributions to the algorithm competition circle...
Participating in the proposition of CCPC this time, even though I have some regrets, it can be regarded as a fulfillment of a small wish.
Hope you all enjoy these topics w