
Hi Codeforces!
I am very excited to invite you to participate in Codeforces Round 1060 (Div. 2), starting at Oct/19/2025 17:35 (Moscow time).
There will be 6 wowee problems for you to solve in 2 hours, some problems will have multiple parts. All problems were authored and prepared by me. This round will be rated for all participants with rating below 2100.
I would like to thank the following list of very strong individuals for making this round possible:
- satyam343 for epic coordination.
- Um_nik for preliminary review.
- The army of testers: Dominater069, sammyuri, __baozii__, Andreasyan, p0tato, _istil, nifeshe, anango, cry, wuhudsm, FetFot, [VIP] reirugan, turska, catgirl, https, That_Salamander, temporary1, -firefly-, [VIP] Proof_by_QED, [VIP+] Friedrich, efishel, Jasonwei08, Hori, Edeeva, welleyth, milind0110, kevlu8, Non-origination, lucaski2, vladimirfilip, dazlersan1, ALnQ417, eric899.
- myst-6 for being too enslaved to test.
- Alexdat2000 for translating the statements into russian.
- MikeMirzayanov and KAN for codeforces and polygon.
- You for participating.
Score distribution: $$$500 - 1000 - (1250 + 1000) - 1750 - 2500 - (2250 + 1750)$$$

UPD: Editorial
UPD2: Congratulations to the winners!
From Div. 2:
From Div. 1 + 2:









As a tester, I hope you enjoy the round as much as I did. :)
wow wow intellij round i love intellij rounds
This not an an intellij round, it is an intellej round
wowee
wowee
wowee
wowee
wowee
woweee
woweee
Lets break this..
wowee
Wowee
wowee
wowee
wowee
wowee
wowee
wowee
wowee
wowee
wowee
Lets break this..
wowee
wowee
woweee
woweee
as a tester, this round reminds me of the good old fish and chips straight from the ponds of great britain.
wowee
As a participant, I hope to reach CM in this round
As a first time VIP tester, I feel very important.
As a tester, orz __baozii__.
orz __baozii__
orz __baozii__
Whenever the problem setter is intelligent, I usually do well in the contest.
Unfortunately the problem setter is not intelligent. He is Intellegent however.
Hopefully, the problem statement will be short and precise just like the announcement. wowee! <3
As a tester, I stared, I ran, I knew, Intellegent's magic coming through.
As a tester, orz Intellegent
as a tester, i got a little too excited while testing
I participated in div3 1059 ,solved 1 and 2 got RE , but i didn't become rated from unrated why is that? ...
You're still rated, it's just you're not a "trusted" participant
$$$VIP+$$$ is a clear example of what happens when you use extreme adjectives too often to describe ordinary things. If you actually used these extreme adjectives properly, then a very important person would basically mean a person who made the round possible. Without them, the round just wouldn't happen. That is very important. So what could a $$$VIP+$$$ person possibly mean? There's just nothing really left for it to describe, and it becomes meaningless to people reading it. Also, $$$VIP$$$ loses some of its significance.
did your grandmother lose significance due to your great grandmother
The comparison you're making here doesn't really work, because 'great' in this case doesn't mean what it usually means. Here it means "a generation older than." No one reads it as "a grandmother that's great" because it doesn't mean that.
This is unlike "very important person" or "legendary grandmaster" as the adjectives here actually describe something I guess you can call subjective in that it's really hard to say objectively that someone is "legendary" or someone is "very important." And because of this subjectivity, people abuse the words and dilute their meaning through overuse.
I know that damn well, I am just giving you an idea that you don't have to comment on literally everything, especially when your opinion doesn't mean jack shit.
yeah chromate00? well the jerk store called. they're running out of you.
Shocking news: american found using ad hominem because there was no other way to logically refute the counterargument
all I see is 2 local clown making entertainment for me before round.
All I see is a spectator seeing 2 local clowns making entertainment before round
All I see is a spectator seeing a spectator seeing 2 local clowns making entertainment before round
All I see is a spectator seeing a spectator seeing a spectator seeing 2 local clowns making entertainment before round
What’s the difference?! You are their all time best seller!
yeah? well I had sex with your wife!
I am in charge of refilling the ice cubes during the round to stop the judges from overheating. No need to thank me though :)
As a student in China, I want the Codeforces Round be at about 11:30 UTC, so that I can participate it straight after school without staying up late. (Well I'd like someone to help me with C++)
wahaha, I thought of helping out(then I saw your rating 400 more than me)
sammyuri let's go it's gonna be fun! My favorite tester
Do they test problems in minecraft?
wdym bro? I don't get it, I don't play mc anymore
https://www.youtube.com/@sammyuri/videos for context
Happy Diwali !!
Don't get offended.
As an Indian, i have a sad truth, this contest would have the best + because all the cheater are not present at the contest time as they were celebrating the festival..
Good Luck for all :)
Real coders will still give the contest.
oh yeah!!!
hope i get to pupil ;-;
wrong post sry
wrong post
ty bro
حبيب البي
I'll test soon :saluting_face:
It was all going fine until I read ‘You need to process Q queries’.
As a tester who forgot to write his tester comment, I hope everyone has fun solving the problems!
i hope i get high rating (pls downvote this comment)
i did not
As a participant, I wish to become CM after this contest
Your wish shall be granted
I guess not this time... hopefully soon though
hope I can reach expert in this contest
so that we cant tell that you are a cheater ha?!
Right, because Codeforces is the only place where real coders are born. Forgive me, a mere heretic who somehow won an award a full year before——imagine that!——being blessed by this site. Should I have it framed for you to finally consider me worthy?
chill out, they call my comment a "joke".
Don't make it personal :)
i will solve 4 problems easily inshaaAlah :) wait for the master performence !
want to learn so much
Intellegent round detected
what is the difference between normal , VIP and VIP+ testers?
VIP+ testers > VIP testers > normal testers
Catshock is a crazy name.
I loved debugging and finally solving C2.
What's the idea of C2? I couldn't get it
You will only use more than 2 operation on index which has minimum brr[i]
i could only solve 2 questions :( How do I improve?
same man, 2 problems.. i guess just keep doing contests and upsolving those that you couldn't do — eventually you will come across the same problems again and you will be very happy!
me too :(:(
Good A-B-C1-C2. It seems like D easier than C2 but I did not have time left
It took so long for me to solve B :(
C be like ImpossibleForces
why you use my name n
You stole my photo my name is Droby and all of codeforces know that
No one knows that you toEv9TKHlcQFlh8JlQETTQ==
fell into the trap of trying to solve C2 before D .. but failed !!!
I realized that my algo was using
MAXIMUM_VALUEwhich is not limited across test cases so TLEWhat's the idea behind C1? I got it eventually but with 100+ lines of code lol, pretty I missed the simple idea
The answer is at most 2 since you can always do one operation on an odd number to make it even.
I got that, but it was hard to find whether it's 1 or 2 (when it's not 0)
the answer can be only 0,1,2 .. so you just check for 0 and 1 .. otherwise answer is 2
check for 0.. two numbers have some prime commoncheck for 1.. iterate left to right .. keep all primes seen till current number, but also check by incrementing current number if we have seen some prime factor for that .. if yes.. we can increase current number and do one operation .. do in both direction ( right to left also ) to keep code simple .. I couldn't figure out one pass so did both directionelse answer is 2... in worst case .. we increase 2 odd numbers to make them both even.well ok, that's what I did, but I was just slow af lol
same for me but C2 .. . stuck in case where we have to increment 1 number only
To "check for 1", you don't need to do right to left. All positive integers x have the property that x and x + 1 are co-prime, therefore you can simply check if (a[i] + 1) has any divisor that was previously saved.
no.. what if like
5,2. . when I go left to right .. and see2.. i have not see any prime factor for3but when I go from right to left and I am at
5. I check for6( 5+1) ... then I have seen2on the right sideam I wrong in understand your point ?
can someone explain time complexity for this, how taking prime factor for each number is passing? wont this be (10^8)
we need prime factors for a[i] .. which is <= 2e5
there is a way to do factorization in
logNafterN log log Nsieve to calculate smallest prime factor2e5 * sqrt(2e5) ~ 89442719.1, which is suitable for running under the 3 second time limit
the answer is <= 2 for sure. then i took the following cases:
first prime factorize every number and for each prime factor, store the number of distinct elements in A that have it in its prime factorization (can store in map)
now, if there are atleast 2 even numbers -> answer = 0
if there is only 1 even number:
1) go through the map to see if freq of any prime factor is atleast 2, that means there exists two numbers with gcd > 1 -> answer = 0
2) else -> answer = 1 (since any odd number can be increased by 1 to make it even and now we have 2 even numbers)
if there is no even number:
1) go through the map to see if freq of any prime factor is atleast 2, that means there exists two numbers with gcd > 1 -> answer = 0
2) go through every number, remove it prime factors from the map. increase the number by 1. find its prime factors and see if any of these prime factors already exist in the map -> answer = 1 else put back the prime factors of original number into map.
3) else -> answer = 2 (increase any 2 odd numbers by 1 and we get two even numbers)
I tried bit similar but I got tle
Two hours is toooooooo short for the 8-problem round. I have no time to think about E :( Maybe it would be better if there were 2.5 hours.
Btw I initially thought $$$O(17985\min(n\log A,17985))$$$ would pass C2 but forgot to multiply the complexity by $$$T=\frac n{17985}≈11$$$ and got two TLEs and wasted 20 minutes :( Has anyone made the same mistake as me?
I couldn't speed up my C2 :(
How do you efficiently calulate minimum operations required where you keep incrementing single element?
I had same issue but managed to find a way out on time...
What's the optimization?
Started with answer= sum of two minimum costs.
Simply instead of adding only I found out how many additions will it actually take for every element in map (which is just frequency of all factors of all elements other than the one with minimum cost) for element with lowest cost of change.according to addition you will have cost and just compare that with ans.
please tell
There are 4 cases only. 0 ops, 1 ops ,2 ops on different index, more than 2 ops on a given index. you only need to check 4th case on index with minimum brr
nooo!!! darnit ..
why is it true that we only need to check for
minimum b[i].. also what if multipleminimumsso you can always make gcd=2 for the smallest two minimum b[i]s in atmax 1 operation on these 2 indexes
oh that is brilliant insight <3
thanks ..
simply sum of minimum two is the max answer you can get so you just need to solve it for minimum one.
yeah!!
couldn't figure that :(
You don't need to calulate it.
The upper bound of answer is very small.
It is the minimum $$$b$$$ plus the second minimum $$$b$$$.
please tell me that is not truee.... aaaahhhhh!!!
ok got understanding from this comment
so how to fast solve case ?
n = 2
a = 1 big_primeb = 1 10^9you need to go from 1 to big_prime, so ans = big_prime — 1
frequency map out all the factors of every element in array except the one with smallest b. let's say val is the element with smallest b then for all elements in map find out how much to add in val to get it divisible by map's key and then accordingly compare it with ans. And max bar for answer would be sum of two minimum b.
IMO, C1 wasn't worded well
"two integers i,j where
1 <= i < j <= nand".
What about the other positions. It wasn't clear if only two positions need to satisfy the above and any pair of other numbers should be co-prime, or if two such positions should exist in the array.
What a great contest, probably my best performance ever
for problem c1 i submitted correct solution at 48 mins but to verify my solution for c2 i tried submitting other solutions so they are considering the last submitted solution or the first submitted solution ? ( I am fucked)(T_T)
last AC
WTF i thought i did lock it so it would not matter. Unnecessary -ve rating
wysi
what ?
what?
wysi
wysi indeed
wysi
wysi
Nice problems, although the round was deeply unbalanced, D was far too easy and C2 was much harder. (Unfortunately I spent like 1h30 on C2 just to get 300 points after 6 wrong submissions and didn't even look at D during the contest)
Problems A-D1 are good, I think; I could've solved C2 if I had ~5 more minutes. Didn't have time to read E and its solve count is low.
Misread C as making all the indexes i,j satisfy gcd > 1 .. Was wondering how that can be done ?
actually your profile pic shows correct expression for this comment ... ha ha !!
I should have moved to D after C1 , D is easier compare to C2 .
C2 is good prob btw. got TLE at 5 :(.
Can anyone explain what's wrong in my code for problem B
...
first part you had done well ,
but for counting ans,
you have to only tackle val at odd positions and if b[i]>min(b[i-1],b[i+1]) then you have to decrease b[i] -> min(b[i+1],b[i-1]) — 1 as b[i] should be lesser than its neigh.
Edge cases -> position( 1 and n )-> where i-1 and i+1 take carefully.
that it for reference -> check My submission
Thanks
Why did my code on C2 got TLE?
unordered_map
Did you write this code? Or used AI to convert from java to cpp?
I don't quite believe you wrote this yourself
struck in C
WYSI
Hi!! When can I upload sources on the problems again? After the system testing?
yes, after system testing is done.
thanks
D statements are the best I've ever seen
Teto and OSU reference in codeforces contest?? what in the multiverse...
anyone notice on C2 test case number 2?
our brains are shrinking
Thinking*
I believe my solution for problem E is incorrect, but it was accepted.more details
Test case 21 for C1 is no mercy, I solved C2 btw. Feels bad.
For me it was just that a[i] = 200000 (and answer = 1 or 2) seems to be only in system tests not pretests, even C2 should have failed at my side but seems such system test was not there for C2.
Can anyone explain why my code gave TLE on C1. Expected time complexity is about O(nlogn). Submission Link
Thanks
There is no limit on a[i]. Having array size of 2e5 in each test case leads to TLE.
2e5 can be factored in log n so overll its just n.logn !?
You create several arrays of fixed size of 2e5 and there are up to 2e5 test cases.
please can anyone tell me what is the efficient process to find the minimum add amount to prime i so that any prime j and gcd(i,j)>1 . suppose i have an array of prime number how to find ???I can not use nested iteration.
Why do you hate me? :(
Sorry
No one noticed my time complexity issue during the contest.
C2 and D were great! Thanks for the contest
I really enjoyed this round! The problems were engaging and offered a good mix of challenge and fun. It was a great learning experience. Looking forward to the next one from Intelllegent and hope to improve my performance. Thanks to the problem setters for organizing such an enjoyable contest!
thanks for the great round!!. Even though i bricked C1 just because i took array size 200000 instead of 200001..
wowwww
dislike my comment it's useless anyways
btw my goal is the last place on contribution top
.
when seeing the first problem and seeing teto and osu reminded me of something
The Intellegent round made me feel intelligent, reached Pupil for the first time
I caught the user ICPCCode cheating in the past contest
oh yes!
Привет, Codeforces
Как добавлять в условия задач белый текст?
Может, знает кто. Сталкивался. Умеет. Помнит.
my sub got WA on test 2 help me plz
344941167
Did literally no one see the hollow knight reference: "No cost too great", "No mind to think", well maybe if it was not TOTALLY HK but still.
I saw it and just immediately went to the comments to check if anyone else did. There's NO way that's a coincidence right
Nope 0 chances
I dmed Intellegent and he said yes it was a reference lol
IG this reply is a little late but dayyum
C1 I cant find what's wrong with my code.I have a same way with answer but i always get wronganswer in 144 of test 2.can anybody tell my how to get a whole test content or
find why always WA 344965003
how the hell is maspy not at the first!!!
Problem E seems to be just a slightly tweaked version of https://www.codechef.com/START203A/problems/SETMED. Even the main idea of the solution is same. I am surprised no one pointed this out given the codechef contest is just a month old.
Handles: vedanshtomar48 and rishipaltomar612 Submissions: 344727962 and 344726280 for problem 2154B
I want to clarify that both of these accounts belong to me. I mistakenly used two different accounts during the contest without realizing that it violates Codeforces rules.
I sincerely apologize for this mistake — it was not intentional cheating. I fully understand the rules now and will only use one account (vedanshtomar48) in all future contests.
Please review my case. I kindly request not to ban both accounts. I’ll delete or stop using the extra one permanently.
Thank you for your understanding.
A really cool question, from C2, you are also given a list of primes, I want C2 but their must be a ai, aj such that i != j, where there exists a prime in the list that divides their gcd(ai, aj), C2 is this question where all primes are in the list.
this is kinda cool try in O(nlog(n)loglog(2e5)) or even faster and let me know
Great questions!
really enjoyed solving these