Hello, Codeforces!
We are pleased to announce the resumption of the Global Rounds. Thanks to XTX Markets for supporting the initiative! In 2025, we will hold 3 such rounds. The series results will take into account the best 2 participations out of 3.
On Nov/06/2025 17:35 (Moscow time) we will host Codeforces Global Round 30 (Div. 1 + Div. 2). 
Codeforces Global Round 30 marks the second round in the 2025 series of Codeforces Global Rounds. These rounds are open and rated for everyone.
The prizes for this round are as follows:
- The top 30 participants will receive a t-shirt.
- 20 t-shirts will be randomly distributed among participants ranked between 31 and 500, inclusive.
The prizes for the 3-round series in 2025:
- In each round, the top-100 participants get points according to the table.
- A participant's final score will be the sum of the points they earned in their 2 highest-placing rounds.
- The top 20 participants across the series will receive sweatshirts and placement certificates.
We extend our gratitude to XTX Markets for supporting the global rounds initiative in 2025!
The 8 problems were authored and prepared by our 8 authors: 244mhq, cmk666, Daniel777, JoesSR, Link_Cut_qwq, NetSpeed1, zjy2008 and me. There is at least one interactive problem, so I strongly urge you to read the guide if you are unfamiliar with the format.
We would also like to thank:
- 244mhq for his excellent coordination.
- Daniel081024, gyydp123_LIM, Little09, operator_, Zhouershan for discussing the tasks with us.
- Dominater069 and Um_nik for
LGM
testing. - GroupMatrix, fake_banana, Imdie, zltzlt, _l_l_, _istil, hxhhxh, Daniel081024, nifeshe and omeganot for
IGM
andGM
testing. - awoo and qiuyuanzhi for
IM
andM
testing. - madlogic, hepp, Hori and Comentropy for
CM
testing. - chromate00, Non-origination and larush for
Expert
testing. - dazlersan1 for
Specialist
testing. - _Jasonshan10_ and decimal10 for Unrated testing.
- 244mhq for translating the statements to Russian.
- MikeMirzayanov for creating the Codeforces and Polygon platform.
- And at last but not least,
You
for participating in the round!
Round Information:
- Duration: 180 minutes.
- Number of problems: 8 problems with 1 subtask.
- Score distribution: 500 + 750 + 1500 + 1750 + 2250 + (2500 + 1500) + 3500 + 5500
GL & HF!
UPD:
Congrats to the winners!
- Otomachi_Una
- Kevin114514
- dXqwq
- ksun48
- VivaciousAubergine
- qiuzx
- strapple
- hos.lyric
- Radewoosh
- StarSilk
- tourist
- maroonrk
- potato167
- Nachia
- BurnedChicken
First Solves:
A: Away_in_the_heavens
B: ksun48
C: Depressed_sad_boy
D: ksun48
E: Kevin114514
F1: Otomachi_Una
F2: Otomachi_Una
G: qiuzx
H: rainboy
UPD2.









It seems this round will be amazing!
As a tester,I think this round will be fantastic
As a tester, I think the problems are interesting.
As a tester, this is my second time testing a Global Round.
As a tester, I can't win a t-shirt in this contest.
as a participant, even if you didnt test, you wouldn't be able to win the t-shirt LLoooooLL
As a tester,I really recommend this round.
As a tester, I hope you have fun!
As an author, I hope everyone enjoys this round!
As a tester, the problems are nice and I encourage you to participate.
As a non-tester, I cannot say anything about this round!! But as a participant, I hope what everyone else does, a +ve delta!!
as a random i think it will be amazing
interested
vro this isn't good and bro is advertising it everywhere
cheater shut up
As a tester who forgot to test earlier, I think the problems are nice.
As a participant, participating in global round is a part of participant's routine
As a tester, I'll be able to sleep early today.
can we participate unrated in this contest? not able to see any such option
no you can't
Hoping for a great round !!! and also reaching back to expert!
orz
I'm from future and I ensure guest_ducbao_ will decrease rating
As a participant, i will try to do 3 tasks
Bruh, only 2
Hope the judges work well.
As a participant, I wish that only worthy people could solve G xddd..
G was AI solvable last time.
Ignore this comment, I misunderstood.
Are hacks disabled for some of the problems like few of the last contests ?
It seems this round will be amazing
can anybody helo me? I ask question after i cannot find any solution. It becomes frequently. So i can solve and write code after reading questions. Is tehre some tips and tricks maybe strategies that u can solve question easily with them. As when u see statement u already know how to this question tip.
A vivid example of why we should remove hacking rewards
Upvote if u did B with Random :)
I found B a bit tricky !! but didn't use random....
how u come to the conclusion n > 100 , then consecutive will give even remainder ?
oh, 100 is not the correct bound.. it should be around
32.. like(1 << 32 > 1e9 )... but I just typed whatever I typed fastobservation
xandyandy < 2x... this pair forms the answerso if we don't find evens .. then if every number is odd and is more than 2 times then it can't increase more than 32 times as it will grow bigger than 1e9... because it is given that numbers are strictly increasing .. so after 32 odd numbers you will find the pair
PS ..
consecutiveafter sorting coz I wanty < 2x.. they will become neighbor after sorting.can you give me the example ?
oh example for which part ???
like the limit of x*32 max ?
thank you! i got it didnt read well to your solution !!!!
oh so you got it now or you need some help ??
sorry if my answer is not very clear
Understood . i just did something random just to pass it :(( .
yeah now I think about it ... random selection should also work !!! .. I spent too much time thinking B ... let's see what editorial has to say
yours is the editorial , i m 100% sure .
hmm .. felt tricky for problem B .. lets see !!!
This solution is consistent with the live commentary on YouTube
yeah, it has passed system tests as well :D
Thanks for the visualizers! I found them to be quite helpful during the contest.
is problem B really just checking each possible pairs or would that result in TLE?
you can prove there must be an answer at arround 30 or 40 numbers.
Problem B:
If you have two even numbers $$$x \lt y$$$ in the list, $$$y \mod x$$$ is even so it's done.
Assume all numbers are odd. If you find two adjacent numbers $$$x \lt y$$$ such that $$$2x \gt y$$$, you're done because $$$y \mod x = y-x$$$ which is even.
Note that if $$$2x \gt y$$$ never occurs, then each number must be at least twice the previous one. This sequence would quickly exceed the $$$10^9$$$ limit, so you only need to brute force the first ~35 numbers. Because of this, even if you write the $$$O(n^2)$$$ solution it will quickly find the answer.
yes that's quite right can u please explain c?? I will be grateful.
https://codeforces.me/blog/entry/148062?#comment-1323661
https://codeforces.me/contest/2164/submission/347775781
this is my code for question B this actually worked , i heard from others that there brute force worked on this but this code is more fun because i used random two indexes for checking(atmost n*100) random index genration was done and yup it's accepted
how did you come up with that ? did you solve some problems like that before ? curious to know
i studied the random algorithm once but this was not much related to it , it was a guess
wait for system testing my friend
can we make a test case where it fails ?
yes for sure i think if the only pair the first and the last is the answer then it will take in the worst case o(n^2) with the random if the seed it not set right but it varies for each problem i guess it will fail in the system testing but i have take 1hr to this problem i cant able to map any pattern the only thing i saw is the sequence is in the increasing order? have anybody came up with another logic or something ?
yeah
https://codeforces.me/blog/entry/148062?#comment-1323661
Each number x has y mod x=2 for atleast half of the numbers greater than x.Thus,if n>30,answer will always be YES,so you can simply write brute fruce.
That's pretty cool. I was thinking of doing the same thing after frustrating 2 hours, but I had no proof for this either. Apparently, one should use pen and paper while solving problems. >:(
Why I find B>C>D. D is just implementation. C reminds me to read the question carefully because I misread the problem for half an hour. B is half guessforces and half mathematical intuition, which I’m unfortunately kinda missing.
sorry, but exponentials/logarithms is as basic as math can get though
Yes B was horrible, D was just implantation base think in reverse direction of string
please share idea for D
Go from reverse index of t to s;
You can only select indexes <= of the current index of t. We just iterate from reverse, making sure to only assign indexes continuously to the left.
The reasoning is: If any of the mapping cross, we are in trouble because, its like you are stretching string s to the right a bit and overlapping some parts, once a part is lost you can't get it back.
Once you have this mapping, its just the matter of sorting the biggest distance a crossing needs to cover, say adbc and aaad, here the 'd' needs to go to the right most part, we maintain a map<int, vector> and iterate from biggest distance to smallest distance and when iterating, append all of map[distance-1].push_back(map[distance] elements),
hmm thanks for sharing your idea...
I had similar idea, but I guess I couldn't figure when the case is invalid .. like the stretching thing you mention
Gotcha, yes whenever you can't go about assigning an index of t to index of s without crossing, we go sad.
Here is how to find $$$s'$$$ from a $$$s$$$ that moves closer towards $$$t$$$:
You can just keep doing these steps until $$$s$$$ becomes $$$t$$$.
thanks for this ... I will try to read and understand it tomorrow !!!
I wrote an even simpler solution that does not require the $$$prev$$$ array: https://codeforces.me/contest/2164/submission/347788909
The idea is that suppose we want to know where $$$t[n-1]$$$ comes from, we find the right-most instance of the char $$$t[n-1]$$$ in $$$s$$$. Suppose that happens to be $$$s[j]$$$. Now, $$$t[n-2]$$$ can only come from any position $$$\le \min(j, n-2)$$$. So, we find the corresponding char in $$$s$$$ for $$$t[n-2]$$$, and so on.
If there is no such $$$s[j]$$$ from where $$$t[i]$$$ can come from, then the transformation is just not possible. Similarly, if $$$i-j \gt k$$$, then that means a char moves more than $$$k$$$ steps to the right, from $$$j$$$ to $$$i$$$, to transform $$$s$$$ into $$$t$$$. Therefore, that is an impossible transformation too. This impossible case can be detected in the first transformation from $$$s$$$ to $$$s'$$$. If it is possible, then just iterate while $$$s \ne t$$$.
Iteration step: for any $$$i$$$ from $$$n-1$$$ to $$$0$$$, if the corresponding $$$j \ne i$$$, then we move the $$$s[j]$$$ one step to the right, so it can reach the index $$$i$$$, eventually. Therefore, we can assign $$$s'[j+1] := s[j]$$$. Rest all the positions in $$$s'$$$, that are left unmodified in this step, can be simply copied from $$$s$$$. Therefore, just initialize $$$s' := s$$$ before doing this step of iteration from $$$n-1$$$ to $$$0$$$.
great, thanks again ..
I found this one simpler to understand.
I will try to upsolve over the weekend
why do O(n^2) even work for problem B ;/ ?
breaks early
actually it's O(n*log_n)
check pairs among the first min(n,32) elements: for each pair x<y, if y % x is even print them; otherwise print -1. Using 32 elements is enough because longer sequences without such a pair would grow beyond 1e9
Can you explain how that happens?
For two odd numbers $$$x, y$$$, if it satisfies $$$x \lt y \lt 2 * x$$$, then $$$y$$$ mod $$$x$$$ would be even. Since $$$ai \lt 1e9$$$, you are guaranteed to find such a pair if total odd numbers are $$$ \gt log(ai)$$$.
I think x<y<2*x is wrong way to compare let's say I have this array where [5,12] here 12>2*5 !
"Two odd numbers $$$x, y$$$". Other cases are trivial.
UPD: Got it, thanks
So... you didn't solve the problem and you are going to lose a lot of rating because of it. How does it make B the worst problem?
Ideally, the worst-case time complexity of O(n^2) when all are odd shouldn't work, but I don't know if I am missing something over here, so if there is any proof, can you explain it?
https://codeforces.me/blog/entry/148062?#comment-1323661
It was already explained to you several times. I don't think me saying the same thing would help, you have to turn on your brain first.
The n^2 code won't run for more than 30n
not about rating i think that is bad problem bro
a problem one can not solve easily doesn't make it a bad one though.
yeah i think im wrong thank u
a problem one cannot solve easily doesn't make it a bad one though.
size of n for -1 answer is bounded by a<=10^9
If array has at least 2 even numbers, any pair of evens should work. Easy to prove.
otherwise check adjacent pairs for the answer. If none of those pairs works which implies a[i + 1] is at least 2 times bigger than a[i], now brute force kicks in.
But shouldn't the worst-case time complexity be O(n^2)?
You don't need to check the whole array.
Since array is strictly increasing, and for 2 odds to not satisfy the conditions, ai+1 > 2*ai. Since ai < 1e9, therefore we can go only as far as log2(1e9) ~ 30 consecutive ai and brute force over them, if there is a satisfactory answer you will find it there.
There will be only ~30 numbers in the array if not able to get any valid pair from adjacent check for case 2.
You did not even read the 2nd case.
If there’s a 1 with any x, or if there are two even numbers, then the answer is trivial.
So we only care about the odd x. Now, loop over all odd x. If you ever find two consecutive odds where (x[i+1] % x[i]) is even, you’re done. the easiest way when you will be done is the following: x[i+1] = q*x[i] + r. where q = floor(x[i+1]/x[i]) and q = 1
If that never happens, we know tat q > 1 and which means X[i+1] >= 2*x[i]. Voilà, the odd numbers double each step, so there are only O(log) of them. Just brute-force those.
For problem C, the input format is like
b1 b2 ... bm
c1 c2 ... cm
But by accident, my first code 347700877 received the input like
b1 c1 b2 c2 ... bm cm
Surprisingly I got all 5 examples correct, so I got a wa. Is it intended? :)
Why I have TL in C, but when I add in always cycle:
I don't get WA
Wow, you have
1 << 5submissions for the problem C. :(whoa!!!
I think if you get TLE, the jury doesn't compare the output.
figured out D with 30 seconds left
What a ride it was!
How to do F? :(
I was desperate when realizing F only had "math" tag but not "dp". I spent yrs trying to come up with some dp stuff.
I considered the pairs of indexes (i, i-1), (i, i-2), (i, i-3) in B, and it passed all the pretests. What the hell? And now i got fst bruh
did you do this after sorting ?
It was already sorted.
oh yeah sorry !!!!
Did you have a special case for 2 or more even elements? Consider the case:
2 3 7 19 22with solution2 22.Why my solution of E doesn't work. First, add all the edge weight as the base weight, and we can only consider the valid vertex with odd degree. Then we use union find to merge the vertex to blocks, if one edge doesn't have any edge in the latter position with weight smaller than it, then we can pair all the odd vertex within the block.
However this solution keep falling at pretest 2 and I don't know the reason why.
counterexample: a component with four odd vertices joined early by edges of weight 100; later a single edge of weight 1 appears elsewhere; when the graph becomes connected, only one pair can use cost 1 at the ancestor, the other still pays 100 (true extra = 101), while your rule would charge 2.
I request that my solution to B be rejudged.
I got skipped, but considering it's a simple brute force(Could not have been simpler), I think I deserve a rejudge
Your first submission for B got skipped not because of plagiarism, but because you resubmitted for the same problem during the contest. Only the last submission for a problem is considered and previous ones are skipped.
Ah, alright! My bad, sorry
Reaching LGM is no longer a dream.
Why is my submission for problem C not being added to the System test queue? The status still shows "pretests passed," but the score for this problem is not in the rankings.
I didn't read the statement of C carefully and thought killing a monster with Ci > 0 would get a new sword with damage = Ci, not max(x, Ci). I find under such condition the problem seems too complicated. So I wonder if correct solution still exists under such condition.
I think my solution should work for that case as well. It tries to use the weakest sword, and then transform it into the strongest sword possible (using this sword for killing). It processes swords in ascending order, then adds all the monsters that it can kill in a ready queue. Now, if the ready queue has a monster with non-zero $$$c$$$, then it will exchange the sword with the largest achievable $$$c$$$. Then the process repeats. Therefore, if the sword was exchanged for a weaker sword, then it will be processed on the next iteration. This greedy approach should work.
I have a similar idea, but don't know what to do when the current sword was exchanged for a weaker sword. Suppose sword with value X now changes to Y(Y < X), since all the monsters with Bi <= X were already added into the queue, how to do with this Y sword exactly?. In my idea, I use a priority queue to maintain the monsters that were added, and I put the monster with the highest Ci on the top. Now X becomes Y, if Y < X, do I have to search in the queue to find the highest Ci among those monsters with Bi <= Y, and continue this process? Seems very difficult for STL or simple data structure to do this.
Hah, I missed that :)
It almost seemed too easy.
haha it's fine. Luckiy I realized I misread the statement during the contest otherwise I am not blue anymore lol
For B brute force seems to be working perfectly fine, which is a little disappointing tbh.
May this day Be The day?
why this solution giving wrong answer on test case number 5.
Great round! Learned a lot from the problems — thanks to the setters and testers for their hard work. Waiting for the next Global Round .
.
Loved the B problem!!
I think Problem B was far more difficult than Problem C. In the end, I just guessed my way through it, haha, guessforce.
Can anyone explain why it not work for C https://codeforces.me/contest/2164/submission/347841876
My submission: https://codeforces.me/contest/2164/submission/347867661
Can someone please help me understand why my code does not work?
The approach is about eliminating the maximum number of Stage 1 monsters using a segment-based approach. The idea is that I can eliminate the monster at index j if the minimum index I can start eliminating from is i.
mai is just the maximum sword power I can get while clearing all monsters in that segment.
As a tester, I'm a tester.
Great contest!
Thanks to authors
the first time I see two unrated testers
Day 2 of asking MikeMirzayanov to add the "Delete account" feature on a random blog.
Can someone explain approach for problem E.
.....
Congratulations to t-shirts winners! In a few weeks you will be contacted via private messages with instructions to receive your prize.
As usual, we used the following two scripts for generating random winners, seed is the score of the winner.
I HAVE ALREADY SOLVED EVERYTHING DONE