Hello, Codeforces!
The China Collegiate Programming Contest (CCPC) is a competitive programming contest series for college students in China, organized by the CCPC Committee, which consists of coaches of the competitive programming teams of Chinese universities. It started in 2015, and this year is the 5th edition of CCPC. There are 4 onsite CCPC contests this year, including three regional contests in Qinhuangdao, Harbin and Xiamen, as well as the CCPC Final in Beijing. Many Chinese universities use CCPC as an opportunity to practice before the ICPC regionals.
The 2019 CCPC Harbin Site has recently ended on October 13 in Northeast Forestry University. A total of 272 teams, most of whom were selected from the preliminary online contest, took part in the official onsite contest in Harbin. The problems for this contest were mostly prepared by retired ICPC participants of Zhejiang University, and the head judge was me.
We are glad to invite you to participate in its online mirror: The 2019 China Collegiate Programming Contest Harbin Site in Codeforces::Gym! Please note that the mirror contest will start at Saturday, November 2, 2019, 18:00 (UTC+8). Click on the link to see when it starts in your timezone. We will be able to answer your questions during the mirror contest. The ghosts of the onsite participants are available, so you may take advantage of it.
This contest uses ACM-ICPC rules and of course, it is unrated. Team participation is recommended, but it is also possible to participate individually. As usual for Gym contests, you may register for this contest 6 hours before it starts, and you will be able to virtually participate and upsolve the problems after it ends.
My thanks go to:
Volunteers and staff from Northeast Forestry University for holding a very successful onsite contest.
Problem authors: lsmll, quailty, Claris, jiangshibiao, shb123 and reku.
Testers: izban, 300iq, and many members of the competitive programming team of Zhejiang University, some of them are: Todobe, wxx_louisa, zx2017, SoSad, zhangqingqi and lyk248289469.
MikeMirzayanov for the powerful Polygon and Codeforces system.
The CCPC Committee and the sponsors of the onsite contest.
We kindly ask everyone who has already know the problems not to participate or discuss them before the mirror contest has ended. Hope you enjoy the problems!
UPD: Contest has ended, thanks everyone for your participation. Here is the link to the official editorial, unfortunately it is in Chinese. But feel free to ask in the comments if you have any questions about the problems.
Auto comment: topic has been updated by lsmll (previous revision, new revision, compare).
One more proof that 300iq is Chinese
If he is Chinese then what's the problem?
long awaited mirror game
How to solve A — Artful Paintings
Binary search the answer. To check the answer, notice that each condition can be transformed into an inequality involving $$$pre_{l - 1}$$$ and $$$pre_{r}$$$, where $$$pre_x$$$ denotes the number of paintings chosen from the range $$$[1, x]$$$ i.e. the prefix sum up to $$$x$$$. Moreover, we have some more inequalities involving the prefix sums itself, such as $$$pre_i \leq pre_{i + 1}$$$ and $$$pre_n = pre_0 + \text{current_answer}$$$.
Let's say we transform all inequalities into the same type $$$pre_x + u \geq pre_y$$$, then we add a directed edge from $$$x$$$ to $$$y$$$ with cost $$$u$$$ onto a graph. Our goal is to find a negative weighted cycle, and if such cycle exists then we cannot build the prefix sum array, else we can always build one ($$$pre_x$$$ is equals to the minimum distance from $$$0$$$ to $$$x$$$).
This is the intended soltion, but we have another $$$O(nm)$$$ solution without binary search.
Can you elaborate?
In binary search you need to check whether there is a negative cycle, so assume a cycle has the cost $$$A\times x+B$$$, we have $$$x\geq -\frac{B}{A}$$$.
So let's just find the cycle with the minimum mean weight using some $$$O(n^2)$$$ formula.
Can you please explain what does an edge from x to y with cost u signify? It is not very trivial for me to understand.
If we take the shortest path from node $$$0$$$ to every other node, then the edge from $$$x$$$ to $$$y$$$ with cost $$$u$$$ enforces that $$$d(x) + u \geq d(y)$$$, where $$$d(x)$$$ is the minimum distance from $$$0$$$ to $$$x$$$.
How would you transform the second rule from the problem into such an inequality $$$pre_x + u \geq pre_y$$$? How would you transform $$$pre_i \leq pre_{i + 1}$$$ into a directed edge (let u = 0)?
$$$pre_{i + 1} + 0 \geq pre_i$$$, so directed edge of weight $$$0$$$ from vertex $$$i + 1$$$ to vertex $$$i$$$.
Hello, sorry if this is a dumb question, but how would you transform this into such an inequality?
The number of painted cubes whose index does not belong to the interval [Li,Ri] must not be strictly fewer than Ki (1≤i≤M2)
That means the number of painted cubes in the range $$$[L_i, R_i]$$$ must be less than or equal to $$$\text{current_answer} - K_i$$$.
I simulated some cases and found that it actually works but I have no idea why converting the inequalities to edges in such a way works for this problem.
Can you suggest any article to gather some more in-depth knowledge/observations?
Thanks
It's just a way to find a solution for an inequality system, where each inequality only involves two variables. It works like that because the shortest path algorithm enforces the inequality $$$d(u) + path(u, v) \geq d(v)$$$ for all pair of vertices $$$u$$$ and $$$v$$$
https://courses.csail.mit.edu/6.006/spring11/lectures/lec17.pdf
My submissions in this contest were moved to practice during this contest and I was unregistered. On registering again and asking for a clarification they replied that they didn't do it and It was a bug or someone else with coach rights did it. It was very displeasing and ruined the contest for me. I think it is trolling by some user which is obviously against CF rules. MikeMirzayanov please look into it. Thanks
Is there any editorial available (maybe, not in English)?
How to solve D?
We have official editorial in Chinese.
D can be reduced to calculate the length of a segment or a parabola using intergration.
Can you please provide the link of editorial.
I have put a link to the Chinese editorial in the post.
Auto comment: topic has been updated by lsmll (previous revision, new revision, compare).
Can someone tell how to solve L-LRU Algorithm
Will there be mirror contest for CCPC 2019 final?
I don't know. The problem setters of CCPC Final this year are from Google China.
First time doing a Chinese contest :'(
On ABCEL, the top 5 teams had a cumulative 63 wrong submissions.
This contest had some harsh time limits.