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
Muhammadali__ Bro, please add the statement to m1, m2, and m3 sites as well. We can't find them in many rounds. Eventually, we have to go back to the original site. Which is annoying.
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 .....
I ignored that first, later found out it was way easier, then attempted and it got AC
Yeah, it was pretty unexpected provided that the question, explanations were pretty long and can sometimes be misleading
Imagine cheating through LLM and commenting about the quality of the contest.
Brother U saying i cheated ? I am more active on other platforms...but i did copy pasted the last ques
Oh shit this means i cheated now what do i do...this will forever stay in submission damm
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
Just a few people.
This is Crazy 13,14,15,15,15 years old only OMG---> 1/0
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
When contribution hunting goes wrong, lol!
At least you gimme upvote, 😔 ! idk why i always get down vote.
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wowee
Wallikumussalam Wa Rahmtaullah
Bhai ki obostha dinkal kemon?
Alhamdulillah akhi
i hope i will get some +
hope I can get specialist this time.
Good Job
Please make me specialist dear problem writers. :orz: :orz: :orz:
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.
oh, I have an exam on Friday next week and I have to prepare for it :skull:
As a (unrated)participant , I will solve problem-set from non-increasing order of difficulty
As a participant, I will participate!!!
Best of luck everyone!!
As a tester,I'm tester
I hit green soon inshallah.
as an Uzbek, I hope to reach spec
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.
I hope to reach Specialist on my Birthday :)
Advance Hb. Best of luck.
walaikum assalam
Excited for my first contest !
As a contestant, I wish to get a huge plus delta:)
Omg! As a participant i wish you guys to get some +
aleykum aslam ya habibi ( i learned a bit of arabic in my school)
Let's go! Will try to reach specialist in this round.
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.
Expecting 120+ delta in this round. Let's see...
وعليكم السلام 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
RankUp contest for me. LFG!!!
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 Pupil, I want to be Specialist after this Round
As a participant,i will try my best to solve all the problem though i am newbie and trying to improve myself.
Same inshallah
good bro
As a pupil I am really afraid of participating due to enormous number of cheaters in div 4
Although I'm not the novice I used to be, I will still participate and miss the newbie I was back then
سَلَام
this is prolly the 1e9th time you may see this, but finally i can say...my first unrated div4!
zo'r, qoyil
Walekumsalam. I'm excited for the new contest. Hope I can solve all the questions in time. 。◕‿◕。
hoping for a positive delta :))
I hope there are fewer cheaters.
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
I can sense a question that mentions Uzbek Plov
is rated?
Wasn't this contest div-3? Am I hallucinating?
Pls I need 1100 score)))
yo time to do my first real codeforces contest
Is it just me or submissions are being "In queue" for real long?
All of us
https://mirror.codeforces.com/contest/2167/status/page/40?order=BY_RELATIVE_TIME_DESC
only 40 page queueu xd
who can tell me what hapend
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!
Screwed up D so bad, found out later it was simple implementation
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 the same thing but also WA on test 2. Could someone please point out 1 test fail? https://mirror.codeforces.com/contest/2167/submission/346354109
it will work. but we need to add 2 values. You can check my submission. i used pair<int, int> with priority queue, first val is teleporter distance from this point and second val is point itself. if we choose this pair {d, p}, we need to add {d-1, p-1} and {d-1, p+1}.
I did Binary Search for E. But couldn't solve D. Why does brute force work for D?
Because the output (x) will be very small (< 100)
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.
Can someone help me understand why binary search over possible longest distances won't work? It feels like my solution does not have a mistake https://mirror.codeforces.com/contest/2167/submission/346313752
Your solution doesn't try to fit in multiple portals in same interval. Also, when l == 0, printing ais is not sufficient, coz positions can be less than k. print 0 to x.
you can see my submission.
I do try to fit multiple, but you're right on the second thing, that was a really stupid mistake, it passed now. Thanks a lot!
My bad!! Didn't see the code properly!
Why are submissions still N/A, i want to do some hacking :(
Too much participants today.
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.
How is max segment tree a heavy data structure? everyone and their mom knows it
Can anybody help me with E? I tried 3 times using binary_search but somehow it's wrong
as a participant, I participated and enjoyed the contest!!
How to hack someone's solution?
How to solve 2167E - khba любит спать!, 2167F - Дерево, ДЕРЕВО!!! and 2167G - Мухаммадали и гладкий массив ?
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.
Thank you
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.
Great questions. Almost did 3rd. Couldn't however understand 4th,5th and 6th.
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
made the same mistake,can somebody tell how can answer go more than 20
I think it is sufficient to brute force values from 2 upto 100 and check if there's any element in the vector for which gcd is 1. that's what i did, it passed all the pretests (not sure whether it will pass the final judgement tho)
why will you check for composites? for correct answer you need to go upto ~60 to include primes which product to >1e+18
Oh yeah, thanks for your help
Just consider the test case
1 1 9699690
Answer should be 23.
For reference 9699690=2*3*5*7*11*13*17*19, it is not difficult to see that it will not be co-prime to every number from 2 to 22
The simplest solution in my opinion is to just run a loop that is always true till you find the smallest number that works. That way you won't have to worry about the upper bound.
yea yea i saw that thanks
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.
Can someone please tell me why my submission for problem 4 is failing on test 4?
try
long long tinstead oflong t, since array values can be upto 1e18in queue
O(n + log(x) * log(n))solution for E: 346394011when will we have editorial?
Problem E was comparatively difficult than F G.
fr
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.
it's showing +ve delta for me. why is my rating not increased yet?
Why is the rating not updated yet ?
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?
the final testing i.e. system testing is currently underway. Results will be out very soon dont worry :)
Alright, Thanks!
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.
when will the rating be updated ? i have my rating below 1400 and yesterday the problems were shown accepted but now they are shown as queued. Help pls
the final testing i.e. system testing is currently underway. Results will be out very soon dont worry :)
okay thanks !!
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.
yes
Kot ekaning javoblarini tashab bemading
When the rating will be declared
my rating for this contest did not inncreased but i got 2 correct when will it increase ?
I sincerely hope, you guys will remove all alt accounts and cheaters from the standings.
WHy after completion of testing, it is showing as an unrated round for everyone?
Why my rating not changed... It is showing unrated?
L rule of trusted participants unfair for new users
Is it UNRATED?????????????????????????????
Probably the easiest codeforces contest I've attended so far.i enjoyed it
What could be the estimated rating of Problem F according to you guys?
what happened to problem A's tags!?
I think E harder than G
I received a notification that my solution 346268159 for problem 2167F significantly coincides with the solutions of several other users. I don’t understand how this is possible, as I don’t know any of them.
If a problem has a standard solution approach, it’s natural for multiple participants to arrive at similar logic, for example for DP problems many of us use tabulation method this doesn't mean that all those who use tabulation method copied the same code. I have received such a notification once before (for one person), which could have been a coincidence, but this time it shows similarities with six different users, and the codes are not exactly the same at all.
I didn’t copy or share(shared after the contest for group discussion) my code. The similarity might be because we used a similar approach or logic to solve the problem.
Hello, I received a plagiarism notice for problem 2161E, saying that my solution coincides with another participant’s code (user: Moooo_temo1). I would like to clarify that I am the original author of my code, and I never shared or published it anywhere during or before the contest.
It seems that the other participant copied my code and even followed the same approach and structure that I used, which explains the similarity detected by the system. I can provide proof that I wrote my code independently (local timestamps, editor history, or screenshots) if required.
I always respect Codeforces rules and the spirit of fair competition. Please review my case carefully.
Thank you for your time and understanding.
Hello, Regarding the plagiarism notice for problem 2167D, submissions •346338866 (handle: chin_may2452) •346340893 (handle: chinmayy949) are both mine. I mistakenly used two accounts, not realizing it would be considered a violation. I sincerely apologize for the confusion. Please treat chinmayy949 as my main account. I will use only this account from now on. Thank you for your understanding.
Hello, I received plagiarism notice for my submission ID:- 346301727 for problem 2167E. I want to clarify that I did not copy or share my code with anyone. The core logic was of using binary search on the distance and then merging overlapping intervals and then used greedy selection is how i solved this problem, so other solutions may look similar. I agree that I have used tools for formatting and also changed my approach of using 2 D Array to using a class.
I didn’t publish or share my code on any public platform.
I really value my profile, and this can hamper my profile significantly. I assure you that I’ll avoid using 3rd party online tools in future contests and will write my solutions fully independently.
Please review my case again. I’d really appreciate it if you could consider this explanation. I am ready to provide further explaination if required.
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
I received a notification that my solution 346713426 significantly coincides with the solutions of several other users. I don’t understand how this is possible, as I don’t know any of them. I didn’t copy my code from anywhere; maybe it just happens to coincide.i write code with my own..i have proofe of my logic ..if you want to know..then you can knock me...i happily tell you about my logic.please review my code once again..i am feeling so sad for this..its not good for me..
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