Hello everyone~ I am Tommy from Shanghai Jiaotong University. I am very happy to participate in the relevant proposition work of this CCPC regional competition. The lecture video at the closing ceremony was too sloppy (the preparation time was too short), so here are the solutions to all the questions. (and some backstory)
gym link : https://codeforces.com/gym/102832
It seems that there are repeated circles in the data of question J, and the validator is wrong, I apologize to the affected players TAT...
Some questions and solutions have not been written yet, so I will make up tonight~
It can be found that except for the first deposit reward, the ratio of the remaining RMB to coupons is 1:10, so we only need to consider how much first deposit reward we can get at most.
Just enumerate all cases directly and violently, time complexityO(2^7).
It should be noted that this question cannot be greedy. (6+28+88+198+328 is better than 648)
Each time the rabbit will choose the closestkOnly turtles interfere, in fact, this is the best choice.
We consider how to do a query, we divide the answer in twot, then the total number of curses needed is\sum_{i=L}^Rmax(a_i+t-(m-1),0), and the total number of curses ist*k,therefore\sum_{i=L}^Rmax(a_i+t-(m-1),0) \leq t*k
This problem can be transformed into using the weight line segment tree to cover the interval balance tree. We can divide the weight line segment tree into two, count the number of weights and the sum of the weights, find the corresponding point, disassemble max, and calculate The answer will do.
time complexityO(n\log^2n), the space complexityO(n\log n).
The practice of AC players on the field seems to be a clever division. (It seems that I am not very good at TAT)
In this question, we need to understand what is called "quantum" geometry. At the beginning, a person can only see a wall, but he can decide his own route based on the current field of vision information.
Divided into two situations:
The first is that the wall you see does not block the end point, so just walk over it.
The second is the wall seenABBlock the end point, then the first step must be from the starting pointSGo to a certain endpoint, may wish to set to go toA.
go toAThen there are two cases, the first isAgo toBthen go to the endT, the second isAgo to the third pointCthen go to the endT. (Also a possibilityACwithBCnot blockedAarriveTroute, just go directly)
In the second case, ifACwithBCblockedAarriveTroute, thenCmust beASreverse extension cord andSTIn the interval of , this area is related toBnothing to doO(n^2)preprocessing.
time complexityO(n^2+q).
Easy to finda_n=c^{popcount(n)}
Enumerate a fixed prefix, considering the number of schemes filled in the second half of the current situation arbitrarily.
Suppose the length of the second half isL, then there iskThe number of schemes of 1 isC_L^k, to count the contribution to the answer.
time complexityO(Len^2)
Consider blasting. The time complexity isO(n\cdot n!), difficult to pass.
Notice that after making a decision, the order of the previous BP does not matter, it is only related to the set of heroes selected, so the number of essentially different situations is only about 900,000, and the memory search can pass.
Memorized search for this question needs to be implemented carefully: one detail is that the number of different options for heroes to choose is actually very small, and the value of all situations can be pre-processed.
Since this question guarantees a large input randomness, game search ALPHA-BETA optimal pruning can be considered.
To be done
To be done
Each operation will change the parity of the sum of all current numbers, so the whole graph is a bipartite graph.
Alice wins currently only if the starting point is on any one of the largest matches. We only need to run the maximum matching of the bipartite graph first, then delete the starting point and run the maximum matching of the bipartite graph again, and judge whether the two answers are the same.
Both Hopcroft-Karp and Dinic can pass this question.
set slave pointudepart, pass by exactlykThe probability of reaching point 1 after one step isp[u][k].
AssumeA[u]=\sum_{i=0}^{+\infty}p[u][i]\cdot x^i ,B[u]=\sum_{i=0}^{+\infty}p[u][i]\cdot i \cdot x^i ,d[u] represents a pointdegree of u .
arrayB is what you want.
easy to spot,A[1]=1 ,B[1]=0 .
next considerIn the case of u\neq 1 ,
A[u]=\sum_{i=0}^{+\infty}p[u][i]\cdot x^i=\sum_{i=1}^{+\infty}p[u][i ]\cdot x^i=\sum_{i=1}^{+\infty}x^i\cdot\frac{1}{d[u]}\sum_{v}p[v][i-1]
=\frac{x}{d[u]}\sum_{v}\sum_{i=1}^{+\infty}p[v][i-1]\cdot x^{i-1}=\ frac{x}{d[u]}\sum_{v}\sum_{i=0}^{+\infty}p[v][i]\cdot x^i=\frac{x}{d[u ]}\sum_{v}A[v]
B[u]=\sum_{i=0}^{+\infty}p[u][i]\cdot i \cdot x^i=\sum_{i=1}^{+\infty}p[u ][i]\cdot i \cdot x^i=\sum_{i=1}^{+\infty}i\cdot x^i\cdot \frac{1}{d[u]}\cdot\sum_{ v}p[v][i-1]
=\frac{x}{d[u]}\sum_{i=0}^{+\infty}(i+1)\cdot x^i\cdot\sum_{v}p[v][i]= \frac{x}{d[u]}\sum_{v}(\sum_{i=0}^{\infty}i\cdot x^i\cdot p[v][i]+\sum_{i= 0}^{\infty}x^i\cdot p[v][i])
=\frac{x}{d[u]}\sum_{v}(A[v]+B[v])
In the formulav withu adjacent.
Find all by DFSA array, and then use DFS to find allThe B array is enough.
time complexityO(n\log n)
Considering DP, letf[i][S] indicates that the current transfer to thei position, thei+1 position to theWhether there is already a closing parenthesis at i+10 positions.
On each transfer, brute-force enumerates theClosing parentheses at i positions (a total of2^5 types), to judge whether it is withS contradicts, and then transfer directly.
time complexityO(2^{15}*n)
Consider the equation firstx\oplus y=gcd(x,y) , sincex \oplus y \geq |xy| \geq gcd(x,y) , so both inequality signs must be taken at the same time. In particular,|xy|=gcd(x,y) . violent enumerationgcd(x,y) andx , judging(x, y) is true. Preprocess all such pairs, time complexityO(n\ln n)
At the same time, it can be found that the number of occurrences of the same number in all pairs of numbers does not exceedc times. (c \approx 60 ) so direct heuristic merge and update the answer from time to time.
time complexityO(cn\log n)
can be found, as long as it is determineda_1 , you can determine(\sum_{i=1}^na_i) The result of \bmod (k+1).
We violently enumeratea_1 \bmod (k+1) , thenThe minimum value of \sum_{i=1}^na_i can be inThe result is calculated in O(1) time complexity. We assert that onlyS \geq min \sum_{i=1}^na_i andS \bmod (k+1) = (\sum_{i=1}^na_i) \bmod (k+1) must have a solution, which can be found inFind a valid one in O(k) time complexitya_1 \bmod (k+1) .
Consider itThe minimum value of the sum after a_1 \bmod (k+1) is taken asa_1 \bmod (k+1),(a_1+1) \bmod (k+1),...,(a_1+(n-1))\bmod (k+1) .
Next, consider how to make the answer bigger, we can first put0 becomesk+1 ; if0 can be used up1 becomesk+2 ... and thus the final sumS. _
time complexityO(n+k) .
Teams that don't pass can tryWhether n=4, k=5, S=8 can construct a solution, many teams WA is at this test point.
(in fact the originalQuestion L is not this question, but it collided with a question of csp on Saturday, so I decided to change it temporarily)