Note the unusual time of the round.
Hello, Codeforces!
Tsinghua University’s Student Association of Algorithmic Competitions (THUSAAC) is pleased to invite you to participate in Codeforces Round 1092 (Unrated, Div. 1, Based on THUPC 2026 — Finals) and Codeforces Round 1092 (Unrated, Div. 2, Based on THUPC 2026 — Finals) on Apr/12/2026 08:35 (Moscow time). This round will be UNRATED for everyone. You will be given 3 hours to solve 7 problems for Division 1 and 6 problems for Division 2.
Please note that this contest contains at least one run-twice (communication) interactive problem. Please read the guides for run-twice problems before the contest if you are unfamiliar with them.
What’s more, it’s the first time that we will provide a local testing tool to help the contestants test their solutions on interactive problems. To get familiar with the testing tool, you may download the sample testing tool for an earlier interactive problem and an earlier run-twice problem. You can download them from the materials of the above problems.
Our team of amazing problem setters include: Warriors_Cat, E.Space, Ecrade_, SpiritualKhorosho, dapingguo8, xiaoziyao, Kratrissa, crazy_sea, zhouhuanyi, Doqe. Some of the problems prepared were not used in the final contest but we would still like to thank them nonetheless.
We would also like to express our gratitude to the following individuals:
KAN for helping to host the round;
Error_Yuan for coordination and helping with the problem preparation;
Alexdat2000 for translating the problems into Russian;
The team of problem setters for crosschecking the problems and also donghanwen, Iam1789, Zesty_Fox, sszcdjr, YuukiS, A_G, nifeshe, Caylex, a_little_cute, simplelife, Serval, wmrqwq for testing the contest and providing us very useful feedback;
Tsinghua University’s administration, especially our advisor Wentao Han for helping us in all means possible to ensure the smooth organisation of the whole THUPC event;
MikeMirzayanov for the amazing Codeforces and Polygon platform!

THUPC is an annual event hosted by Tsinghua University’s Student Association of Algorithmic Competitions (THUSAAC). It is the largest student-run competitive programming contest in China with the top 100 Competitive Programming teams from all over China coming onsite to vie for the crown of BEST CP Team in China after qualifying from a pool of 1000+ teams.
Moreover, this year is the 10-th anniversary of THUPC. Years of a decade have distilled countless brilliant and sparkling moments, and our gathering today is no less memorable. Our sincere gratitude goes to all staff and volunteers of THUSAAC. None of these glory would have been possible to be realized without your efforts!
By experiencing a series of collisions between intellect and joy, we hope you will enjoy and have fun in the contest. Good luck!
The scoring distribution:
Div. 2: $$$500 -1000-1750-2250-2750-4000$$$
Div. 1: $$$750-1250-1750-2750-3000-4000-5000$$$
UPD: Due to technical reasons, this round will be UNRATED. We are really sorry for any inconvenience caused by this :(
UPD2: Reasons of being unrated: The official contest started 3.5 hours earlier than the codeforces round. The problem statements unexpectedly leaked from the public scoreboard shortly after the official contest begins, and it spread a bit widely before the codeforces round begins, so the round can't be made rated now... We apologize for our mistakes :(
UPD3: Editorial









As a coordinator, THUPC is a good contest!
Although I broke my arm before the first round of thupc thus losing the chance to participate the final contest onsite, I'll still participate it on codeforces. Good luck everyone.
qp
orz
Finally a communication problem for a Codeforces contest. And wait, is it a communication AND interactive problem?
hope this will be easy for me
İ agree thia too
I hope it goes well!
Hope theres no guessing problems
Though there're many tough days,I believe I can make it(to get higher rating and reach master!).
PS: I wish one day I can contribute my problem for the following THUPCs in the future!
Though there're many tough days,I believe I can make it(to get higher rating and reach candidate master!). :heart:
Though there're many tough days,I believe I can make it(to get higher rating and reach expert!).
Though there're many tough days,I believe I can make it(to get higher rating and reach candidate master!). :heart:
Notes that the round is already unrated, Just relax.
Why does it have to be on Easter?
Hope not to solve 0 problems again.
I just want to have my usual behavior.
[Delete]
Contest at lunch for me :D
Same for me too... Wait, you are also Vietnamese.
looking forward to contest, hopefully i can get till E without being goombah stomped though given my skills i doubt it
As a participant, I can feel that the contest is gonna be interesting.
I am familiar with interactive problems. But not with run-twice problems.:(
Lets see how it goes ! GL!
I hope that this contest is my Comeback contest.**I believe myself**.
I hope it'll go well.
All the best.
THUPC competitions are always of exceptionally high quality, featuring problems that require deep thinking and successfully blend tradition with innovation. I look forward to this year’s event maintaining its consistently excellent standards!
I believe a well-designed problem set not only fosters greater growth among participants but also provides a more accurate reflection of their true skill levels. Lately, we’ve often seen contestants achieving high scores through the use of AI, and the reason is often that the problems lack depth, relying solely on excessive code volume to create difficulty. I believe a well-crafted problem set can also provide greater fairness for those of us who compete honestly!
On a side note: My teacher once said he would treat anyone at our school with a Codeforces rating over 2100 to a meal. I can’t wait to earn that treat! I hope THUPC will be the stage for this milestone achievement of mine!
The code provided for the local testing tool in the Link is a single line of text which Python isn't able to interpret. I got it reformatted from ChatGPT but that doesn't feel like the intended way.
The download link seems to be broken. Here are the source codes:
Thanks :)
It can be the difference between UNIX and CRLF.
For me,it's a friendly time!I don't need to stay up late!Brilliant!
6:35am guess im cooked :sob:
Good timing!
Finally I can participate a round in the afternoon! also I wish I could win Gaokao and enter THU... but I lost badly...
Hope everyone enjoy the contest!
morning round, finally
4 hours left. Where’s the score distribution?
This is the first competition I have participated in
My first contest since feburary!
I've been waiting for days to this contest and now is unrated
This reminds me of last year's Zhili Cup. It looks like some kind of curse; any THU contest on Codeforces is very likely to be unrated because of some unexpected events. This is truly unfortunate.
So what are the underlying causes of this situation?
Probably problem leaking.
That's such a shame—I was actually hoping to reach a 2100 rating in this tournament.
hhh
Ffs why is this unrated now, I woke up early for ts and now it’s unrated
seems like the problemset has been leaked
As a PKUer, I want to condemn THUSAAC for causing me to lose the opportunity to become candidate master.
As a non PKUer. I want to condone THUSAAC for causing me to lose the opportunity to become expert.
Wait, lose the opportunity to become expert???
RagebaitForces
THU Round unrated again :(
Morning warmup round I guess
CHINESE PROBLEM SETTER :O MUST BE HARD THAN AS USUAL DIV2
Told ya, the contest will be hard :)
even if it’s unrated, I’m still willing to participate
Let's put the link of leaked problems here and look forward to a nice result of the unrated round.
The only competition that fits my schedule has also been unrated…
I would've had to skip lunch to give this contest.
Sadge, it became unrated. But hey I'm gonna go have some food now!
same
Woke up early today for this contest, now I can go sleep again!
pechalka ||-||
It was my 1st Div.1 contest and sad to see that it's unrated :(
same T_T
why it is unrated?
What means "technical reasons"?
The problems were leaked :(
Back to sleep.
Waking up early for a rated round only to see it become unrated is a bit disappointing, but ensuring fair competition is always the right call. Thanks to the technical team for their hard work.
they should've careful about sharing questions. i didn't wake up for unrated contest. but thanks anyway for your hardwork.
where it got leaked?
Where is the "fun" you've given me?
Nice pun in the name of div1E.
Why are you cheating on an unrated round???
Div1 D and E should be swapped.
Did a 3-hour contest only to find out it was unrated. Should’ve just slept.
Do not use vector on Div.1 B or you will get TLE :(((
I used vector and didnt TLE
How to solve Div1E?
Consider lining the points by $$$x_i$$$ ascending. From front to back, if there's a peak, add the triangle and smooth out the point(line $$$i-1$$$ and $$$i+1$$$) and repeat the same process for the valley, just like polygonal triangulation.
Thank you
Testcases in problem B are weak
370786015 fails on this test:
1
999999572915
Answer should be 9, my solution gives 8.
How to solve D2E / D1C... is it something related to topological order or something constructive.
Assume vertices are 0-indexed. The goal is to assign 0/1 color to each vertex, such that the sum of color[i] * 2^i = s. For every vertex, you know its desired final color. When you get an edge u, v you direct it from min(u, v) to max(u, v) if color[u] = color[v], and from max(u, v) to min(u, v) otherwise. Since color[n — 1] = 0, you can reconstruct the color array
We noted that the range of the num is 1~2^n ,the first step is to take the number down by 1. It is to ensure that the nth bit is always 0
Now we can rebuild the tree in this way. If we have 1 edge and two endpoints called u v ,if the uth bit and vth bit of s are the same,we make the direction of edge from max(u,v) to min(u,v) .if not we make the direction reverse. (You can check it by check the xor value of them).
Once we rebuild the tree in this way ,we can restore the orignial number by the basic dfs ,start with point n,checking the edge direction,and we can restore each bit value of the number.
In this way we get the orignal number,don't forget add 1 to it before you output.
I hope this text can inspire you! Hope you enjoy your day.
Thanks got it!
This contest is really interesting.
orz
Who also felt that div2B is quite annoying, it took me more than 2 hours to solve it :(
This contest was so good, except that it was unrated :(
Thank you for the problems, especially the communication problem (Div1C) =)
Div1 D is so weird, I guessed that the distance should always $$$\le 12$$$ and directly passed?
How can we explain that?
Now I know. My submission has been hacked.
POV of "I'm sure it will pass system tests" coders.
A somewhat valid one nowadays with little difference between pretests and systests. Not like those past uselesspretestsforces rounds were good but this sounds like a case that's easy to countertest so it should at least have a counter in systests.
I created video editorial for C. Interval Mod and video editorial for D. RReeppeettiittiioonn
Can someone please tell me why is my solution wrong for B 370775032. My logic was, since using T and U together saves us most space, we always pair them first and then if no T is left, the answer is 3*(H + U). If T is left, then we have a choice, EITHER we pair T and H (taking 5 space) and then take care of remaining T or H (for H it will be 3 per item and for T we can pair it with itself and add 3 if its odd) OR we first pair T together with itself and add 5 for last one (if odd) with H, and then add 3 per H left, we take the minimum of these two values.
for input:
1
2 1 0
it gives 5 instead of 7. After packing T and U (size 4) pack THT (size 7) and then remaining k * T for cost 2 * k + 1
I also used similar approach mine also failing. Two cases to consider when T,H remains and U finished.
case1: pair TH then invert T (7 rows ) then either H finished or T finished. if T finished it’s H*3, if H finished pair T’s horizontally 2*T+1 rows
case2: pair T’s horizontally 2*T+1 rows. pair H’s 3*H rows. if one T only then consider merging it with first H then all Hs.
Then we take min of case1 and case2. And add to initially combined U and Ts.
And if U and H remains T finished it’s simple total count of H and U*3 because H and U cannot be combined.
nvm i got it. there was a silly mistake in case1. i forgot to add 3 when pairing with 2T and 1H lefts us exactly 1T.
I was not able to deduce that case 2 can be less than case 1 as per your solution can you think of a tc where this happens
You can try this test case:
1 2 1 0Your code will print 5, while the correct answer is 7. Also, you can see that 2 Ts and 1 H only need n = 7 for them to fit, not n = 8.
Thanks, got it. I missed that we can pair 2Ts and 1 H with 7 space.
Too sad that this round became unrated...
Interesting problems, sad that is was unrated. (Or good because I suck.) Waiting for editorial...
Please Explain how in Div2C testcase 5 is having answer 4 ??
I can't figure it out ???
Please Help
You can first select [1,4] and mod 3 turn it to 0,1,2,0,100,78,4
Then select [4,7] and mod 5 turn it to 0,1,2,0,0,3,4
Then select [4,7] and mod 3 turn it to 0,1,2,0,0,0,1
Sorry for poor English
can we not just mod every a[I] with either p or q until a[I] is less than both p & q? If I am wrong please correct me. for example : ll sum = 0; for (ll i = 0; i < n; i++) { while(a[i] >= min(p,q)){ a[i] = min(a[i]%p, a[i]%q); } sum += a[i]; }
U need to check for a subarray of atleast k size
There will be different cases made out from here
Though I couldn't solve but i really believe my approach was not wrong at all
Ohh man!!
I really tried hard to apply dp soln
But now i got it what went wrong
Thanks a lot !!!!
div 2c? I am also not able to figure out... for test case 5 I am getting 584 instead of 569
Anyone can tell the ratings of problems a,b,c , were quite easy however i found d difficult even thou it got solved by quite many?
Same
Personally I think problem D is easier than problem C; it only took me about half the time of problem C.
"It is guaranteed that the sum of n over all test cases does not exceed 10^12." This statement is rarely seen when n is greater than 1e9. Therefore, I guess the time complexity should be O(sqrt(n)). If it were O(log) or O(1), there would be no need to add this strange restriction.
Let's discuss b separately:
If b>sqrt(n), then b^2 > n, this means that n has only 2 digits in base b. Lets rr(b-base) = n, r*b + r = n => r(b+1) = n. we only need to find the divisors of n that are greater than or equal to sqrt(n).
If b<=sqrt(n), since the time complexity allows, we can brute-force enumerate each b. While enumerating, we also found all the divisors of n, thus solving the first case.(One more detail, if n is represented in base b as r1r1..r1r2..r2...rk...rk, let num[i] = num of ri, then p should be able to divide all num[i].)
Here is my code 370783848. Only need to look at the "solve" function at the bottom; the rest of the code comes from the maspy's template lib link.maspy's library is very powerful and free to use, thanks him.
ooops! I didn't notice this and solved the problem in $$$O(d(n)+n^{1/3})$$$, where d(n) means the number of factors of $$$n$$$,$$$\le 7000$$$ when $$$n\le 10^{12}$$$.
This algorithm can actually solve the problem without the condition $$$\sum n\le 10^{12}$$$.
Will the problems appear in the problemset/be given ratings?
Already in the problemset, and will be given raiongs.
Editorial pleaseee
Where's the editorial?