Assalamu alaykum, Codeforces!
We are extremely excited to invite you to first-ever-Uzbek contest Codeforces Round 1062 (Div. 4), which starts on Oct/28/2025 17:35 (Moscow time). You will be given $$$7$$$ problems and $$$2$$$ hours and $$$15$$$ minutes to solve them. We hope you will find the problems interesting.
The problems were authored by khba, Muhammadali__, JahonaliX, Nasa and Isamatdin.
The format of the event will be identical to Div. 3 rounds:
- ICPC rules with a penalty of 10 minutes for an incorrect submission;
- 12-hour phase of open hacks after the end of the round (hacks do not give additional points)
- after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated
- by default, only "trusted" participants are shown in the results table (but the rating will be recalculated for all with initial ratings less than 1400 or you are an unrated participant/newcomer).
We urge participants whose rating is 1400+ not to register new accounts for the purpose of narcissism but to take part unofficially. Please do not spoil the contest for the official participants.
Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating unsporting behaviour. To qualify as a trusted participant of the fourth division, you must:
- take part in at least five rated rounds (and solve at least one problem in each of them),
- do not have a point of 1400 or higher in the rating.
Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.
We would like to exceptionally thank:
- Vladosiya and soullless for wonderful and epic coordination.
- Kevin114514 for red-black testing.
- physics0523 for red testing.
- Friedrich, reirugan, Saturnalorbit, [VIP+] djm03178, [VIP] Intellegent, Odminbey, Arpa, catgirl, [VIP] Timosh and [VIP] cry for orange testing.
- [VIP] chromate00, khos, thismagic and M1LLI0N_PP for blue testing.
- MikeMirzayanov and KAN for the great platforms.
- and last but not least, You for participating!
Good luck to everyone and enjoy the problems!








Auto comment: topic has been updated by Muhammadali__ (previous revision, new revision, compare).
Why are there 0 div4 rated testers (not even any specialists)?
agree++
contest ID 21**67** :skull:
This is actually crazy
Been a while, but sharing my video of winning the round + (quick) solution explanations: https://www.youtube.com/watch?v=lgPxucqRazM
As an author, i hope you really enjoy it and get +ve delta <3
it was great contest
the 3rd problem almost got me to make an algorithm like bubble sort because thats what i learned in cllg today..
but u knwo how problem C was .....
Imagine cheating through LLM and commenting about the quality of the contest.
As an author, I have nothing to say except for the fact that all authors' ages are between 13 and 15.
I'd like to ask that how can I be an author since I'm a 14-year-old student
Write problems and then propose contest
Isn't 2009 16 y/o now? (hello fellow coder)
Maybe he will be 16 soon
Really???
Yes, here are the respective ages when we started making problems:
Muhammadali__ were $$$15$$$ years old when we started creating problems, then they aged $$$16$$$ during the process (their birthday was close). $$$14$$$ in the previous message was a typo.
Well happy birthday to Muhammadali__, but I would like to ask you...how?
13-year-old expert?
14-year-old MASTER??
Call me dumb, but they're GOAT-ed
Nobody tell him that Kevin114514 was lgm at 14
WTF, REALLY? He is 14 years old?!?!?!!???
Oh yeah, wonderful! One of the 60 LGM(probably less at the time) is 14 years old!
I know a guy who is 9 years old. He's almost at LGM. Right now he is Newbie.
Jokes aside, I would really like to know HOW? I don't plan, nor do I think I'm getting LGM, but I would really like to be Expert or pass 1500(I keep making dumb mistakes)
I believe it's called Chinese wisdom
I agree but I don't
It can't ALL be chinese, you know?
I mean, there are so, so, so many Chinese people who are Newbies. And even without counting them there are a whole lot of Chinese people that are NOT LGM.
So the reason for a 14 year old LGM can't be JUST Chinese
i am agree with u. However in fact it is true that chinese are excellent in maths, programming etc
I know u from RFO group. Are u a medalist?
Yea :) But it was a mere bronze last time.
I'm planning on getting gold and maybe FOF
And again, I know about Chinese being GOAT-ed but Kevin114514 is on a different level
Ig he's just the chosen one
That's one way of putting it :D
upvote if you don't know where uzbekistan is on the map
i know it's one of the only two doubly landlocked countries in the world :)
bonus if anybody knows the other
second one is Luxembourg ig
not a bad guess, but France, Belgium, and Germany are not landlocked (they all touch the North Sea), so Luxembourg is only singly landlocked
Liechtenstein maybe
AC
Kyrgyzstan
close, but China touches the Pacific, so Kyrgyzstan is only singly landlocked!
As I know where Uzbekistan is, I will downvote you ;)
Hope this round is free of cheaters
حلم ابليس بالجنة
I hope that I solve all the problems within the time...
As a tester, I hope you all achieve your best performance. GLHF :)
orz!
orz
i fell from spec to pupil last div2 just for this, hopefully getting a good perf :)
As a participant, I hope everyone gets a good +ve delta.
Walaikum Assalam! If you don't know about uzbek-famous food. Upvote
What is actually uzbek-famous food?
pilaf ofc
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
hope I can get specialist this time.
Good Job
I have sacrificed a Div. 2 to do this officially, I hope this will be good :)
As an author, I did almost nothing.
bekorchisande
As an author, thank you for your participation.
As a (unrated)participant , I will solve problem-set from non-increasing order of difficulty
As a tester,I'm tester
I'm really looking forward to this match.
As a tester, I solved all problems before the contest. I made a video. Don't miss it. It'll be published here.
I wish every Codeforces contest had at least one mandatory interactive problem.
thanks for dislikes
Owalykum assalam
As a VIP+ tester, I hope everyone to be VIP+ participant.
Omg! As a participant i wish you guys to get some +
Good luck everyone. :)
Hope Everyone gets positive delta:)
Timur once said JahonaliX is the strongest cper ever. Even though I wont participate, I am sure it will be a nice round.
وعليكم السلام I’m looking forward to enjoying this contest!
I never knew that there were no contests earlier organized by Uzbeks earlier. Iranians did something earlier. I guess central Asia is catching up. I hope cheaters don't spoil the round though.
As an author's friend, I hope everyone will enjoy the round
As a participant, I hope I can solve more problems than in any of my previous Div. 4 contests.
I really hope u will!
As a participant,i will try my best to solve all the problem though i am newbie and trying to improve myself.
Although I'm not the novice I used to be, I will still participate and miss the newbie I was back then
سَلَام
As a Codeforces User JahonaliX orz Nasa orz
Hope It will be a Great Contest for Beginners Inshallah
The only bad thing(in my opinion) about be[user:__baozii]ing a tester is that you don't get to participate in the round.
Especially if you test a lot of rounds like cry and __baozii__ for example, they don't get to participate in as many rounds as other people. For some lazy people this is good but for goats like them this is bad since they don't get to feel the thrill of solving and competing
Well it doesn’t really matter to me if I can’t participate in div2-4.
Well, I know rating-wise they are pointless, but it's still fun, in an addictive way.
If the problems are easy for you, then it's a race to see who solves them all faster, which is fun because every minute matters.
But then again, you have been coding for a long time, and after so long, it's not the same thrill as always
Wish to go to Oita:)
Hoping for 7 out of 7 after the hacking phase ._.
I will try to hack you ;). I added you to my friend-list. Say good bye to one of your problems(probably).
S##t, your codes too strong
really like the way you want to hack him;))) Can I add you to my friend-list?
Of course, why you asking?
thanks :) u can try again in the next contest
Of course i will try to hack one of your codes, you win a battle, not war.
I feel number of upvotes/downvotes proportional to +ve/-ve delta. Hope the community wishes good for me!!
why there is no testers < Expert?
As a tester, i tested
As a participant, i will try to hack LonggVuz
Is it just me or submissions are being "In queue" for real long?
i see many ppl are doing G as chatgpt is solving it. G has more solves than F.
If you have cheated by solving G, congrats your account will be banned.
Many people know dp, but not many people know trees man
You can't convince me that G is harder than F. G is an obvious dp problem right from the beginning and the caveat is just to solve it iteratively with space optimization. F, on the other hand, needs some "smart" thinking (At least I didn't solve it in the contest).
First time to AK a live contest in codeforces ^_^
Thank you so much for this contest guys <3
Why n=8000 and timelimit is only 1s in problem G?
for O(n^2) ?
Sadly constant optimization is needed for some language under this constraint even for O(n^2) solution..
I think they must have tested python performance on G.
no idea, btw your code TLEs because you create a new dp-array on every iteration,
i will learn from this..thanks a lot!
good contest
For E, does something like keeping a priority queue of ranges where we can insert teleports not work? basically, at every iteration pick the longest range and place a teleport at the furthest position in that range (in the middle if the range is between two friends), and push the range with size one less than the old range. I kept getting WA on #2 for this would love to hear your guys thoughts on this.
I did exactly this idea with a priority queue. Maybe you can check my solution? It's not a really pretty solution though lol, but it works.
I did Binary Search for E. But couldn't solve D. Why does brute force work for D?
the product of 1st 30 primes is greater than 1e18, so any number smaller than 1e18 wont contain all of these primes, and so iterating first few primes will surely result in gcd=1, with atleast one element from array.
Why are submissions still N/A, i want to do some hacking :(
I love the contest
At least I think we should have a G2 with $$$n\le 2\cdot10^5$$$....
Yes, N log N solution with BIT or SGT !!
Yes, the intended solution should have been $$$nlogn$$$ for that. But I think as this was Div4, authors didn't want the coordinate compression technique to be used at all.
Yes, we tried to avoid heavy data structures since it's a Div4 contest.
Great problems nonetheless. Thanks for being an author of the round.
Can anybody help me with E? I tried 3 times using binary_search but somehow it's wrong
How to solve 2167E - khba Loves to Sleep!, 2167F - Tree, TREE!!! and 2167G - Mukhammadali and the Smooth Array ?
E — Binary search on ans, I found it similar to Aggressive Cows, but messed up a bit, so wasted a lot of time there.
F — You need to understand the pattern. Basically, you need to calculate how much each node contribute to the final answer. You can do that by going through each adjacent node of a particular node.
G — DP, something like longest increasing subsequence. I found it easy to think like what if instead of removing the elements and minimizing the sum, we keep the elements and maximize the sum. Recurrence: dp[i] = c[i]+max(dp[j]) where 0<=j<i && a[j]<=a[i].
Couldn't get the time to solve F and G in the contest though.
Why is this solution not working?
It's not right for you to be so greedy. For instance, if the i-th element must be chosen and there exists a j > i such that a[j] > a[i], it's possible that c[j] is very small but a[j] is extremely large, which would lead to a higher cost for selecting subsequent elements.
Here is a set of samples for you.
1 5 3 10 2 100 4 66 33 1 1 45
The answer is 35.
great round, my friends all love it.
Can anyone give hints in E problem?
binary search on maximal distance + modeling of possible positions with the given distance
If it is possible to place $$$k$$$ teleports, it is possible to place $$$k-1$$$ teleports too. You can assume a distance and check if you can put k teleports maintaining that distance.
i have got 2 correct my rating doesn't increase why?
Rating updates take place a few hours after system testing ends which will start after the hacking period ends
Nice contest. Submitted D within 25 minutes but got wrong answer 4 times and later saw the constraints and changed int to long long. Dammm I spend one hour because of my silly mistake and bloated the opportunity to be in top 5k.
I submitted D within 13 minutes but because of the queue it took over 15 minutes to check, it turned out I didnt switch int to long long, so I just wasted all that time
I think G would've been a more interesting problem if the constraints were higher.
As someone already suggested, there should have been a G2.
I submitted the G2 solution to G because was not confident in N=8000 with one second.
Excellent problems.
Can you explain F?
You can see a bijection between the condition of "is LCA of a set of k nodes" and "subtree size larger than or equal to k", since there is always a way to do so (e.g. choose the root, then k-1 other nodes). Thus, we can solve this problem with a simple DP with rerooting, simmilar to 1092F - Tree with Maximum Cost.
For problem D, it was stated that the value of aᵢ can be up to 10¹⁸, but on test case 4 I got a Wrong Answer because there was a value greater than 10¹⁸.
I tried to use brute force with x values up to 20, which means calculating up to 19! and that’s where the value jumps from 10¹⁸ to 10¹⁹, which shouldn’t be allowed according to the problem constraints.
If I’m wrong, please correct me.
ok
why will you check for composites? for correct answer you need to go upto ~60 to include primes which product to >1e+18
Does Binary Search work for D? (I've read that some people brute forced it and it passed the pretests) But if anyone has solved it with BS can you please share your solution so that I can get an idea?
It won't work with binary search.
it Accpeted.
346321899
My Code for Que E without using binary search.
First sort all friend positions, then consider every empty gap — before the first friend, between each pair of friends, and after the last friend. Each gap’s middle point (or two middle points if the gap is odd) gives the position where a teleport can be placed to maximize the minimum distance to any friend. These candidate positions are pushed into a max-heap along with their gap size. From each middle, you can expand both directions: forward (ok = 1) or backward (ok = 0) — this allows gradual filling outward from the widest spaces. For special cases, if 0 is not among the friends, you only move forward from 0 → a[0]; if the last friend’s position a[n-1] is less than x, you only move backward from x → a[n-1], since there’s no friend beyond the boundary. Then you repeatedly pop the largest gap from the heap, place a teleport at its position, move one step in the indicated direction, decrease the gap, and push it back. This process fills the biggest empty regions first, ensuring teleports are spread out to maximize the time before the first friend reaches one.
in queue
O(n + log(x) * log(n))solution for E: 346394011when will we have editorial?
Problem E was comparatively difficult than F G.
why does bruteforcing upto first 100 primes work for the problem D. Also can anyone tell the minimum no of primes we need to check for bruteforcing ?
Because any number <= 10^18 can be divisible by at most the primes <= 47 (their product ≈ 6.1×(10^17)), the smallest coprime must be a prime <= 53, so checking the first 16 primes up to 53 always suffice.
let’s look at multiplying primes: 2 × 3 × 5 × 7 × 11 × …
In other words, for consecutive pairs where gcd(x, y) > 1 to keep appearing, the product of consecutive primes must keep growing.
So, you only need to check up to the first prime z where 2 × 3 × 5 × 7 × … × z >= 1e18.
Hi, everyone!. I participated yesterday and successfully solved 6 out of 7 problems, but still I have not been rated in this contest. I qualify in fourth division with rating less than 1400. I am new to codeforces so would like to know if I missed something?
I like how it takes you half an hour to solve C, 20 mins to solve B, but you take 5 mins to solve G.
Problem G should come before Problem E, even though its constraints have been increased to 1e5.
I play this round but still did not get the new rank , is it rated ?
Yes It's rated.
System tests are running now on all solutions. After that the ratings will be updated.
I sincerely hope, you guys will remove all alt accounts and cheaters from the standings.
What could be the estimated rating of Problem F according to you guys?
I received a notice regarding similarity for submission 346336538 for problem 2167E. I want to clarify that I wrote my code myself locally in IntelliJ IDEA on 28 Oct 2025 — the file was created at 20:58 and compiled at 21:56, as shown in my project history. I did not share or copy any code. I have the original IntelliJ project with timestamps and Local History available for verification. I have taken screenshots which show timestamps for my project file proving that I wrote the code myself and made several changes in it over and over again to ensure it was working on all given sample testcases. I can send them privately
Thanks for contest. Problem [problem:4022A] is the best.
maksad?
Hello, I have received a plagiarism warning for my submission [346324720] on problem 2167D. I want to clarify that I did not copy or share any code during the contest. The other participant and I study at the same university, and we learned similar coding approaches in our programming course. That might be the reason why our codes look similar. It was not intentional, and I will be more careful in future contests. Please review the situation again. Thank you.
orz
great contest
I received the plagiarism warning for submission 346333219 for problem 2167F.
I would like to clarify that the parts of my solution which coincide with other submissions come from a standard, publicly available reference and were not copied from any other contestant.
My Source is a publicly avaibable book: Advanced Data Structures for Olympiad — Papangkorn Apinyanon.
You can find the exact implementation and explanation on page 15 of the PDF: https://me.papangkorn.com/advdsoi.pdf
This is a standard code that I learnt it from this book and used my own variation for standard DFS subtree-size computation and the common loop pattern over tree edges used to compute pair contributions (subtree size s[u], n — s[u], and the conditions checking >= k). My submission follows this standard template that might be the reason for the coinciding code. The algorithm and the code structure are textbook-level and widely used in competitive programming for tree subtree counting tasks. I didn’t publish or share my code on any public platform. I request you to reconsider my code and remove Contest violation from my Codeforces account.
i love questions especially b. May be nezuko from ds and mikasa from aot? i love anime and i think this questions are really interesting