
Привет, Codeforces!
Серия образовательных раундов продолжается благодаря поддержке программы Computer Science and Artificial Intelligence (CSAI) в Neapolis University Pafos со стипендиями от компании JetBrains.
В 18.05.2026 17:35 (Московское время) состоится Educational Codeforces Round 190 (Rated for Div. 2).
Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.
Задачи раунда будут частично пересекаться с внутривузовской олимпиадой Саратовского ГУ (запланированной на 17-е мая), поэтому если вы студент Саратовского ГУ, планирующий принять участие в олимпиаде, мы просим вас пропустить этот раунд.
Вам будет предложено 6-7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.
Задачи со мной придумывали и готовили Адилбек adedalic Далабаев, Максим Neon Мещеряков и Александр fcspartakm Фролов. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.
Я бы хотел поблагодарить тестеров задач: shnirelman, awoo и FelixArg. Ваш фидбэк по задачам нам очень сильно помог!
Наконец, что немаловажно, у нас есть сообщение для вас от наших друзей из Neapolis University Pafos:
Финальный этап приёма на программу бакалавриата BSc in Computer Science and Artificial Intelligence в Neapolis University Pafos уже открыт.
Ключевые даты:
Крайний срок подачи заявки: 9 июня 2026
Обязательный вступительный тест: 14 июня 2026
Подайте заявку, чтобы получить шанс стать обладателем одной из 40 стипендий JetBrains Foundation, которые покрывают:
полную стоимость обучения
проживание
ежемесячную стипендию
визовую поддержку
Подайте заявку сейчас и подготовьтесь до финального дедлайна!
Удачи всем участникам! Я надеюсь, что вы получите удовольствие от решения задач и узнаете для себя что-то новое.
UPD: Разбор опубликован.









I love you guys
Love it!
And here we go, $$$6 - 7$$$ problems again...
reminds me of that round 1090
i am lazy
不错不错
Bro don't speak Chinese on Codeforces
Thank you for your reminder.
hi
Div4 and educational rounds are the rounds we like the most.
Hope For Interactive Problems
If the round announcement doesn't specifically say there will be interactive problems then there won't be interactive problems
?
I bet the hacking phase will be awesome!
Be very careful with hashing!
GL & HF!
Lesssss gooooooooo Educational Round here we go
Must be the water aaaaah Moment
hope this contest will be better than previous one:)
Agree.
Educational rounds never disappoint. Time to solve A–B confidently and get humbled by C.
Hope this gets me expert
Interesting round, except for the fact that I will lose nearly 50 ratings after this round ;). Meanwhile, my friend is going to reach CM...
who ask bro?
erm actually, it's "who asked bro?" and not "who ask bro?"
$$$D$$$ was so easy, had no time to solve it.
If only I hadn't gotten stuck on trash can problem $$$C$$$.
skill issue, next
Sure, enjoy more constructive problems.
I apologize for wasting everyone's time
??
chill bro
what's the intended solution for D, am i stupid for using a nlogn solution?
i have O(n) DP-like solution, working from right to left
Its simple DP. You have to compute a helper DP at indices where $$$a_i = b_i$$$, like if you both had watched that episode at that index then how much further segments they can still watch before you find a bad pair. And then use this DP later for smaller $$$i$$$. Sorry if explanation is bad but hope you get the idea.
At each index $$$i$$$, let $$$dp_j$$$ be the number of subarrays ending at index $$$i$$$ in which we've already watched $$$j$$$ movies ($$$j$$$ can be 0). Based on $$$a_i$$$ and $$$b_i$$$, we only need to update a few elements in the $$$dp$$$ array for the current $$$i$$$, and then we add all values from $$$dp_j$$$ to the answer. This can be done efficiently by keeping track of the sum of $$$dp$$$ at each point in time, making it $$$O(1)$$$ for each $$$i$$$ and $$$O(n)$$$ overall.
I think the easy way to think about this is that each $$$(i, i)$$$ determines what we are interested in next in $$$(i+1,i+1)$$$, $$$(i+1, x)$$$ or $$$(x,i+1)$$$. This creates a single outcoming edge. Having this sort of tree structure, you can just DP on it to know where the chain ends if you start in some $$$(1, 1)$$$.
375107486
Backwards DP. Let dp[k] be max day that Alice and Bob can reach if they enter the current day with k episodes watched so far. For each day i, if a_i = b_i (say =k) then the max day they can reach from state k-1 is the same to max day they can reach from state k, so dp[k-1] = dp[k]. Otherwise, they cannot even progress past the previous day, so dp[a[i]-1] = dp[b[i]-1] = i.
Answer is sum of dp[0] — i for each i. Time complexity is O(n) for each test case.
You can keep track of valid left points for every point i by storing their mex value if they survive till point i. When entering a position you can create a new starting position. If a[i] != b[i], all left points whose mex value are a[i] or b[i] dies at this point, so you just need to add all left points that are alive at every index i.
375130209
i m so ashamed of india's coders bro . they just wont stop cheating man. I hate my countrymen for this.
I got humbled bad man...
Had no time to solve E :p
.
why so overkill?
notice that for a given person, we have 5 cases: (1) the optimal p is 0, and optimal c is 0, (2) optimal p is t+d, optimal c is 0, (3) optimal p is 0, optimal c is t+d, (4) optimal p and c are both t+d (5) the optimal uses the raw value of p+c
what can be done is to sort the values c[i] by the key p[i], and vice versa, then build suffix and prefix minimums on them. this allows us to efficiently query the first 4 cases, by asking for example "what's the minimal p-value amongst all i such that c[i] >= t + d?". you find by binary search the location of first c[i] where c[i] >= t+d, then use the suffix minimum to answer the query.
for the final case, we can just store a segment tree on the values of p+c, sorted by p[i]. then make a query in the range [t, t+d] for the minimum. why does this work, even though the minimum might use a c > t_c? it works because our other 4 cases will have caught that, so even though p+c ≠ I(p,c), it doesn't affect the answer as it is larger than the actual value and we are taking mins
this account is a cheater(AI) account that doesn't know what he's talking about
Am I wrong or it can be solved just considering following cases:
1) p is 0,take minimum such c by binary search 2) c is 0,take minimum such p by binary search 3) p+c is minimum over all the array 4) p is minimum over all the array 5) c is minimum over all the array
It passed the tests
.
In Education round I got educated in problem D
I was trying to write some dp with two kind of DP, while storing next values' index coming from right to left
solution if we start here and we watch an episode on this day,
solution if we start here and we don't watch an episode here
but got confused in implementing it, I was writing too many
if-elseis there a simpler way to code this, or some other ideas ?
Get a dp array at each i where a[i] == b[i] which means the right bound if we have already watched 1..=a[i] movies. The transition would involve cases like the next a[i]+1 in both a and b having the same index or not.
Then for each starting L, find the next position of 1 in both a and b, if they are the same index, ans += dp[ix] — i, else ans += min(ix_a, ix_b) — i.
thanks, I was writing same and was sure it is correct but I am looking for simpler implementation I guess, because I was not able to simplify it.
Define $$$dp[L]$$$ as the minimum $$$R$$$ such that the subarray $$$A[L \dots R]$$$ is bad.
The first movie has to be $$$1$$$. Suppose it is present at indices $$$a_1$$$ and $$$b_1$$$. If $$$a_1 \neq b_1$$$, then $$$dp[L] = min(a_1, b_1)$$$.
Otherwise, $$$dp[L] = dp[a_1]$$$
How to compute $$$dp[a_1]$$$? Notice that $$$a_1$$$ contains a $$$1$$$, so the first movie that you watch from this point onwards is $$$2$$$, so you locate the next occurrence of $$$2$$$, suppose it is $$$a_2$$$ and $$$b_2$$$. If $$$a_2 \neq b_2$$$, $$$dp[a_1] = min(a_2, b_2)$$$
Otherwise, $$$dp[a_1] = dp[a_2]$$$
Submission
thanks I will check this out !!!
Can anyone Tell me why it got TLE 375137614 Why O(nlogn) got tle
I was happy until "running on test 15".
If I understood your code correctly, it will TLE in an input of this form:
Since for each
1you are going to the next largest integer, this code will take $$$O(n^2 \cdot \log n)$$$ time (for each1, you are traversing the $$$\frac{n}{2}$$$ list of numbers from $$$2 .. n/2 +1$$$)I think a tighter bound can be proven (O(n^2)). because for every possible left end point (Say L).we are doing binary search to find first 1 at index >= L (say it's i1) now we will do binary search to find first 2 at index >= i1 and so on. Now the amount of times we will do binary search is O(n) but the runtime of every binary search is O(log f[i])(where f[i] is the number of times element i occurs in the array) so the total runtime of all binary searches for a given left end point would be upper bounded by (sum of log(f[i])) over all i (because we never binary search for the same element again given the left endpoint is fixed) which is log(sum of f[i]) which is O(log n) . So for a given left end point overall runtime is O(n + log n) which would be O(n^2 + n log n) or O(n^2) overall.Reply if anything seems wrong.
I don't quite get how you arrived at $$$\sum_i \log f[i] = \log (\sum_i f[i])$$$. A better argument would be to use the concavity of log function to arrive at
where $$$n_d$$$ is the number of distinct elements. The last inequality is possible because of the monotonic nature of $$$\log(.)$$$
From this we get that $$$\sum_i \log f[i] \leq n_d \cdot \log (\sum_i f[i]) \leq n_d \cdot \log n \leq n \cdot \log n$$$ (Since number of distinct elements $$$\leq$$$ number of elements)
Using this inequality we arrive at the same $$$O(n^2 \cdot \log n)$$$.
Please correct me if I am wrong.
Oh sorry I forgot to change sum to product there. But i also have another question if we only use the inequality u mentioned on the left side. Then sum of log(f[i]) <= n log((sigma f[i])/n) If we substitute sigma f[i] = n here on right right side something weird is happening. Like Sum of Log(f[i]) <= n log(1) (Got it now thanks)
Even if you use product, I think if you use some bounds from AM-GM, you are likely to get the same bound.
Secondly, I think it is a slight oversight from my side in using the wrong notation. The $$$n$$$ in the expression should be replaced with $$$n_d$$$ where $$$n_d$$$ is the number of distinct elements. However you can bound it in a similar way (not too hard)
EDIT 2: Made the necessary changes in the original post
EDIT: The inequality I'm referring to is Jensen's inequality (https://en.wikipedia.org/wiki/Jensen%27s_inequality). The inequality is right; just an error in notation :)
got it , i just have to store (memoize it) it like {next int,index} so next time whenever i reach i directly call the answer
This is my O(nlogn) solution 375186318
To handle cases like [1 1 1 1 1 .. (n/2) times] [2 3 4 5 ... (n/2)+1]
Use: if(a[i]==a[i-1])curr_r = previ_r;
I wish I thought of this optimisation during the contest :(
Now it gets TLE :(
Can someone explain where I am wrong in B? Remove all 4s+min((count of 1+count of 3 before last 2),(count of 2 after minimum index of 1 and 3))
idk I did the same sol as u and kept screwing up on test case 2
Exactly
I am getting frustrated by recent contests
For this test case
1 1 1 2 2 2 2 2 3 3 3 3 2Logically speaking, you are only considering 2 strategies: removing ALL ones & threes, or removing ALL twos. You are not considering any hybrid strategies.
I took a slightly different approach and considered the count of 2s remaining after when deciding which path to take 1. remove all the current two 2. remove all the ones + threes before
Consider the test case:
1 1 2 1 1 1 1 1 2 2In this test case your code will remove the first 2 ones and last 2 twos with a cost of 4. Whereas you could've just removed all 2's.
I think you are just missing the case when you have to remove all the twos. Another check outside the loop might work.
EDIT: The additional check doesn't work.
thanks lol; just checked the sol and realized where i went wrong. better approach would've been just to remove all 4s, then look at the string every time there is a three/one to check if its worth keeping the previous chain of 1/3 or the chain of 2s instead (persistent count that is never reset), adding one to account for the 1/3 just read. At the end you add a final check (like u mentioned) for cases where there are no 1/3.
Yeah this is exactly what I did. I too missed the check outside the loop in my initial submission :)
Can you explain your logic?
Its obvious that we need to remove all the
4s. Now iterate from left to right and consider we encounter a1or3at the ith position. We have two choices from here:1(or3). Then I will be forced to remove all the2s to the right of ith position. Once I remove all the2s, it automatically becomes a valid configuration. The cost for this is $$$\text{count of (1s/3s)} + \text{suffix_count[i]}$$$1(or3). Removing this single occurrence is added to a counter. Immediately removing this character doesn't make it a valid configuration, so we have to continue this process until the end.You can come up with a loop invariant to show that for every iteration i, once we remove all the prefix
1s and3s, removing all the suffix2s from here is a valid configuration. This is required to justify the expressionans = min(ans, cur + fours + twos[i]);I used the same idea and got WA2 :(
anyone used DP for B or just dump me..
375152428
B is so hard :/
i didn't see condition where numbers are between 1 and 4, so i solved for 1..9 (
But i really liked problem E, although i did ~200 lines implementation xD
I spent too much time for B but can't solve it. Feel it's harder than C :)
thanks for useful samples in C!
ABC is easy, D is hard asf.
And you didn't even participate.
how many problems you did?
Relatively simple E, just ran out of time smh
me too :(
Good job stealing my profile picture
yeah, who would do such a thing?
wow what a hypocrite
yeah sorry i did do that
the worst “B” in ever for me
In 375138399, I got a mysterious Compilation Error with error message
g++.exe: fatal error: cannot execute 'C:/Programs/gcc13-64-winlibs/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/as.exe': CreateProcess: No such file or directory
I submitted basically the same code 3 minutes after and got AC: 375139568
I've forwarded this issue to the admins, they are investigating it currently. Your submission will be rejudged
375122442 Can any one help get a test case in which this fails? Main idea is to count at each step if I am encountering an 1 or 3, I am checking count of 2 and count of (1 + 3) till that point and adding the minimum to my answer and discarding all counts of 1 , 2 and 3.
Try:
Can someone see my profile and say how do I practice I am stuck on div2 contests sometimes I do 2 sometimes 3 I want to reach level of 4(mostly) how do I practice I prefer solving codeforces problemset no tags as per choosing rating what do I choose Thankyou:)
How to get rid of huge constant in E?
Anyone else felt C easier than B?
easily
anyone felt D was harder than E?
There is a $$$O(n\log n)$$$ solution for D with Fenwick Tree which can be optimized to $$$O(n)$$$.
At each index $$$i$$$, if $$$a[i]==b[i]$$$, it can either extend all valid segments ending at $$$i-1$$$ that have watched until exactly episode $$$a[i]-1$$$, causing both Alice and Bob to now watch episode $$$a[i]$$$, or extend all valid segments ending at $$$i-1$$$ that have watched until some episode other than $$$a[i]-1$$$, but both Alice and Bob do not watch the current episode.
If $$$a[i]\not=b[i]$$$, then any valid segment ending at $$$i-1$$$ that have either watched until exactly $$$a[i]-1$$$ or $$$b[i]-1$$$ cannot extend past $$$i$$$, since only one of them would be watching the episode. All other valid segments can be extended, provided neither $$$a[i]$$$ nor $$$b[i]$$$ are equal to 1.
With a Fenwick tree, we can maintain the number of valid segments ending at $$$i-1$$$, where the next episode to watch is $$$k$$$ for $$$1\leq k\leq n$$$, and update the counts of valid segments using point update, and doing a range sum for $$$[1,n]$$$ for each index. This leads to an $$$O(n\log n)$$$ solution. Submission: 375183000
We can observe it's not necessary to maintain a Fenwick tree. We can just use a $$$count$$$ array. The only change is we now have to keep track of $$$total$$$ — the total number of active, valid segments ending at $$$i$$$. This reduces the complexity to $$$O(n)$$$. Submission: 375184626
Who else solves E in $$$O(n+q+V)$$$ ?
Hi
why always there is an overflow hack and it is not in main tests in edu rounds ?? T__T why even keep 1e9 constraints on values :( just int <--> long long causing bug hurts ::( BledDest
3 problem was something difficult to understand
Why ten hours for system testing + edi?
i think its long queue thats why.my one solution is in queue but now i paste same solution that is accepted
After 35 contests and over 220 days practice I finally reach master again
with the amount of time system testing took I think you will officially be master next year
congrats dude
I participated as rated, but this contest is showing in my unrated contests. Plus there is no change in my rating.Why?
Same .showing as unrated for mine too though i participated as rated
It's normal, we just need to wait sometimes happens
Weak pretests in E.
what
when will the contest rate us (please forgive my bad english)
Hope I will reach expert after this contest!!
wheres the editorial ganggg
its out, link
also do you mean "wheres the editorial" or "wheres the people begging for editorial"?
Does anyone know why is it taking so long to update the ratings and why is it showing in unrated contest list in profile -> contest??
till the contest rating changes are not released the contest appears in unrated contests section in the profile, educational rounds take more time for ratings to be released.
why long ahh queue or is some testin still going on
I solved 2 questions in this round but my rating drops 33 why? I cant get this actually I am new to this can anyone explain why this happens morever I submitted solution in single attempt only
Because you submitted too late, even without wrong submittions the penalty is too high which puts you at rank 9000+, rating change depends on that.
I understand the concern regarding similarity. I solved the problem independently during the contest using the standard two-pointer approach commonly used for this type of problem. I did not intentionally copy any solution. I will also make sure to use a more distinct coding style/template in future contests. Thank you.
Respected Team members,
As my solution was found similar to some other contestants solution, I would like to say that i solve all my questions using the preexisting self made boilerplate in each and every contest. it seems the format was very similar of both the solutions but i guarantee you that there was no connection between both the solutions and i wrote mine the way i usually write them. Please check this issue and a response on this issue would be helpful. And the logic was pretty straightforward for the question as it was just counting which section of either (1's and 3's) or 2's will be the least plus the total nos of 4 to stop the formation of 12, 32 and any nos including 4.
bada_bhondu
Hello respected members , I received a notification saying I'd violated a rule in my submission of 2230C - Arrange the Numbers in a Circle . Could I please talk to one of the organizers/admins to appeal against this violation . I havent committed any form of plagiarism and had structurally broke down the questions into 2 cases when we had one vs multiple cards of frequency > 1. I did some trial and error and derived the exact formulae for both cases and implemented it. I did use a standard template which wasnt similar to some of my previous submissions which was a mistake on my end but the implementation was purely my own. If needed I can provide screenshots of the code in my ide or any other form of legitimacy. Could someone look into this it'd mean a lot thank you !
easy round!
BYE BYE XVIII
I solved 4 questions, but it is still showing skipped on my end and my rating has not been updated.