
Привет, Codeforces!
Благодаря поддержке Neapolis University Pafos, продолжается серия образовательных раундов. Университет предлагает получение степени бакалавра в области компьютерных наук и искусственного интеллекта со стипендиями JetBrains. Получите передовые навыки в области искусственного интеллекта и машинного обучения, которые подготовят вас к востребованным техническим карьерам. Доступно ограниченное количество стипендий. Не упустите свой шанс учиться в Европе бесплатно!
В 06.07.2026 17:35 (Московское время) состоится Educational Codeforces Round 192 (Rated for Div. 2).
Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.
Вам будет предложено 6 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.
Задачи вместе со мной придумывали и готовили Максим FelixArg Новоточинов, Адилбек adedalic Далабаев и Роман Roms Глазов. Мы бы хотели поблагодарить Майка MikeMirzayanov Мирзаянова за создание Codeforces и Polygon, без которых этих раундов бы не было.
Также мы бы хотели выразить благодарность тестерам раунда: shnirelman, Brovko, awoo, Alenochka, paomur. Спасибо за помощь в подготовке контеста!
Удачи в раунде! Успешных решений!









I will be live with post contest discussion stream here
As an sc3developer, hope my computer doesn't fall into a bottomless pit this round
wow!
Why not "6 or 7 or 67 problems" this time?
cringe
use the word "cringe" is cringe
You too used this word.
Letsss Go...
Good luck to all participants!
Good luck to all participants!
Time to get humbled by c again. -:lol:-
If it's Neapolis we cooked again
How many questions should I aim for in a div 2 contest to reach pupil. In a 2 hour, 3 hour long contest, does the number or timing expected from one change?
if you consistently solve 2-3 you should reach pupil easily
i dont think so in one contest(it was div 2 actually) i solved A,B,D and score 2000 but i was newbie and didnt effect my rating much)
well you had +88.. a few of those and pupil is easy... just be consistent
consistently solve 3 and you might scratch specialist 3-4 each time reasonably fast for expert
I'm consistently getting A-D but still stuck in specialist :(
I think the problem lies in your solving speed and not consistency
There’s no fixed target. It depends on the contest difficulty and how everyone else performs. In most Div. 2 contests, consistently solving around 3–4 problems is often enough to be around the Pupil level, but that can vary significantly. A 3-hour contest usually has harder problems rather than a higher expected solve count.
Ahh another edu... goodbye purple
Ahh another edu... goodbye purple
"goodbye purple", its time to get orange
Do you guys recommend a unrated guy to join?
.
yay, another contest! lets have fun!!
Hello,
This will be my first CF contest, i hit usaco plat in march and wanted to do this for fun to see how it is in comparison
any tips?
Good luck and have fun! Btw , congratulations for hitting USACO platinum.
Thank you!! u 2
Fight for Master go go go
yes, good luck to all participants!
I hope A and B are easy like old problems, there is no point of making A and B much harder but still solvable by AI
I hope A and B are easy like old problems, there is no point of making A and B harder but still solvable by AI
i need to find the guy with tnt pfp
Thanks for the round! Good luck, everyone!
Good luck!!
Good luck!
I love problem C.
Problem C is peak
seven submissions for last problem
As a graytist (graytist != ratist btw), nooo I'm getting back to newbies after this round.
I'm certain I would get +9 rating points in this (I'm 1191 before contest btw)
UNO reverse
Hell naw :sob:
I'm also 1191 and certain that i will become pupil
3k solves for D is crazy
Can F be solved with persistent treaps?
Just normal treap is enough: 381509946
Also nearly identical to the usaco problem?
facepalm
It can be solved with a persistent implicit AVL tree, used as a rope / sequence tree.
$$$A, B, C$$$ were kinda standard, as expected for a Educational round. But $$$D$$$ was a good problem!
D is a cool problem, sad that I solved it 3 minutes before the contest ended
.
C was a pretty good problem imo, seeing the reduction was a good part of it.
.
so close to solve c, wasted a lot of time on b, i dont know why :(
just solved c , a -1 was missing :((
D is a nice DP problem!
Yeah , i am TLE on 10 test case.Do u know the solution to it? D problem?
Damn, i bugged my solution for C but still, great contest!
First time I saw where we actually do the operation mentioned in the problem (B) and it works, otherwise mostly its some mathematical equation which solves the problem in O(1) or log. C seems out of my way, need to upsolve now, but loved the problems.
got 3 minute late to submit E!
how to solve D?
My whole thought process & solution for D.
observation 1: a & b are possible to make equal when sum(digits_a)%10 = sum(digits_b)%10
observation 2: We are combining 2 consecutive digits. If we perform operation on multiple consecutive digits, it can be to seen that We are actually combining blocks to form a digit in final number
How can we combine blocks in a & in b such that for every corresponding block sum(digits_block_a)%10 = sum(digits_block_b)%10 ?
observation 3: We know we have to make each block equal then why not iterate from left to right and make a block equal one-by-one.
Now the only problem remain We have to maximize final block counts.
observation 4: We know,
block_a_1 % 10 = block_b_1 ... eq1
bock_a_2 % 10 = block_b_2 %10 .. eq2
adding eq1 & eq2 => (block_a_1+block_a_2)%10 = (block_b_1+block_b_2)%10
And if we can add 3rd block then 4th and so on..
We can generalize it as,
Prefix_sum_block_a[i]%10 = prefix_sum_block_b[i]%10 ... eq3
from eq3 we can observe that if prefix_sum_a[i] % 10 == prefix_sum_b[j] % 10, then the i-th digit in a and the j-th digit in b could mark the ending of same block.
In simple words we want a sequence from prefix_sum_a %10 which is equal to sequence from prefix_sum_b %10 and we have to maximise this sequence/blocks/length of resulting string.
This can be done using finding longest common subsequence from prefix_sum_a & prefix_sum_b both modulo 10.
code: 381515191
B was a disaster
Just use Prefix Sum + Suffix Max.
I'm not good at this kind of problem. I struggled on B for 1.5h and ended up with a segment tree solution and finally passed B. Then I passed C in just 20 minutes but got negative rating delta. The order of problems of this round was just a disaster.
You're a f***ing genius brother.
it .
I saw some people solving B using just brute force, and I don't know why it works!
I think it probably has something to do with the nature of the problem. Even Im not sure but I think its something along the lines of if theres too many segments that satisfy the left part then the middle part will probably be satisfied or smth like that. Im not sure.
How about... solving F using brute force too? Loop interchange does wonders... also
#pragmais doing the heavy lifting here... constraints too small, unhackable...weak pretests ig
seems like an n^2 solution to me, but it got ac. Can anyone explain why ?
..
I wasted so much time optimizing this. Post-contest, my friend showed me their brute force got AC. Absolute pain.
2 brute force solutions for B have already been hacked. The similar submissions will probably result in a TLE verdict during system testing.
Define
$$$p[i] = pref_1[i] - (pref_2[i] + pref_3[i])$$$
$$$q[i] = (pref_1[i] + pref_2[i]) - pref_3[i]$$$
The inner loop runs when $$$p[i] \geq 0$$$. Consider the first index $$$i$$$ for which $$$p[i] \geq 0$$$. Since $$$p[i]$$$ shifts $$$\pm1$$$ at a time it's guaranteed that $$$p[i] = 0$$$ or $$$p[i] = 1$$$ here.
At this point, we will begin scanning $$$arr[i + 1 : n]$$$ looking for a suitable middle segment.
Case 1) We find a good middle segment and are done.
Case 2) We don't find a good middle segment. This implies that $$$q[j] - q[i] \lt 0$$$ for all $$$i \lt j \lt n$$$
Consider that $$$q[i] = p[i] + 2 \cdot pref_2[i]$$$
Subsitute to get $$$(p[j] + 2 \cdot pref_2[i]) - (p[i] + 2 \cdot pref_2[i]) \lt 0$$$
$$$p[j] - p[i] \lt 0$$$
This inequality is the crux of why brute force works. It states that from $$$i + 1$$$ onwards, we never improve the balance of $$$p[i]$$$.
Recall from earlier that $$$p[i] = 0 $$$ or $$$p[i] = 1$$$ when $$$p[i] \geq 0$$$ for the first time.
If $$$p[i] = 0$$$ then after a failed scan at index $$$i$$$, we will be left at $$$p[i] = -1$$$ (note, a failed scan implies that $$$arr[i + 1] = 3$$$ as otherwise a length one middle segment would work) and we will never need to scan via the inner loop again as it will be maintained that $$$p[i] \lt 0$$$ from then on.
If $$$p[i] = 1$$$ then after a failed scan at index $$$i$$$, we will be left at $$$p[i] = 0$$$. From then on, we are back in the prior case and can scan at most once more.
Total time complexity is $$$O(n) + 2 \cdot O(n) = O(n)$$$
TLDR the inner loop can run at most twice.
I looked into it and I don’t think it’s hackable.
I have the same solution :)
I thought my solution for D would be fast enough but it TLEs and I'm not sure why :(
My idea is that it doesn't matter in which order you apply the merges, and every merge can be represented by a mask. So for example if a = 12345 and mask = 1101 then we would get 69.
Then I loop over all masks for a and b, which should be small amount, and check if
merge(a) == merge(b), and track the longest merge.I thought I might've been too slow because I was working with strings when merging, but even after changing to working with ints I TLE on test case 10. Is it possible to make my solution work, or is this approach completely wrong? :P thanks for reading
I think it will be time limit because len(a) >= 5*10^3 so 2^(5*10^3) is very huge which you can't complete even in a week. you code is running in o(2^(len(a)) and my ans run in len(a)*len(b)*10 using dp
I just realised that it's the length of a which is 5*10^3 not a itself. I am so silly. Thanks!
:-(
wasted 1 hour thinking constraint was 1e5 for both the strings in D :((
Just wondering about C, there is any solution for which having a sorted array makes things any easier? My solution works by generalizing contiguos equal numbers as blocks so i really don't use that sorted fact at all, i wonder if i've made things more complicated by not using that fact
yes having them in sorted order removes issues like say you have 11122111, here performing remove operation 2 times, makes it 11, it can make our operations kinda complicated
Ohhh i get it, then i do use that fact XD Thank you!
Brother i would really appreciate if you could help me here like where did i mess up the derivation
help me where i went wrong
so either all bordering elements are deleted or multiplied
so either no*of unique elements are deleted ; or they are multiplied
so u can assume for any set ( 1,1,2,2,2,3,3,3)
is equal to (1,2,2,3,3) cause u can easily get it as diff would be divisible by the no of unique elements present
and if we are aiming for size k : it wouldnt matter if we started on either of those above array i gave u
lets save that above array as freq {1,2,2 }
here since bordering element are same deleted or same added
if for a k ;; a element with freq f is present in that construction then b element with freq f also must be present in that condition and would be in the same way to reach that construction
starting from lowest freq 1 , cause ;;
if we do any operation 1 would be gone and wouldnt be able to contribute in further formation of arrangements that reaches 'k'
and for that elem with freq 1 to reach the element whilst its present ; it must have a min freq of [1] ;;
so the difference of element caused to make that element reach that freq of one so we can further construct would be —
Current_freq_total — or n number of element lets say n ;
so while making it one all the element having frequency greater than or equal to 1 will also lose equal amount of freq -> let that unique number be occurence -- and it would also be the no we will lose or gain if we do further operation in it
so diff = n — { occurence * (currentfreq — 1) ) ::
also here occurence would be
so ;; our aim is size = k
so to be able to reach size_k ;;;
it would have to be aim = diff + x*occurence ;;;
or for this to be feasible ;; aim- diff % occurence should be 0 ; so if this is the case we do ans ++ ?? no where did i mess up my derivation
it fails on the test case
3 1 1 2 2 ****
it gives 2 instead of 1 its supposed to output and this is the main codeblock
Thanks for your time , really appreciated ;;
you missed one boundary condition that causes it to overcount.in your first iteration (freq=1), aim becomes -2. Since -2 % 2 == 0, your code does ans++. your formula assumes a base frequency of 1. adding that adjustment gives a final frequency of 1 + (-2 / 2) = 0. if the frequency drops to 0 or below, those elements are completely deleted and can't form a valid array of size k. to fix it, just make sure the resulting frequency is strictly greater than 0. i made similar error lol
ahh , now i see it // i forgot to verify the conditon with aim>=0 ;;; wasted almost whole hr of contest forgetting to check smth so basic, thanks!
Perhaps the fact that you treat consecutive identical numbers as a single entity already relies on the property that the array is non-decreasing. To give a counterexample, if it were an unsorted array, then in the worst case it would mark N elements.
Yeah i'm noticing it only now, thanks!
The problem F made me get Master!
I felt like the first four questions in this match are too easy. I solved them in 40 minutes. They don't seem like Div.2 level difficulty.
And among them, B is much harder than the other three.
Editorial of D+E
https://codeforces.me/contest/2242/submission/381527708 D. Say after operations the first digit is merged from A[i1:i2], second digit from A[i2:i3], etc. and similarly for B[j1:j2], ... Then if P are the prefix sums of A mod 10, and Q of B mod 10, we want P[i1] = Q[j1], P[i2] = Q[j2], etc. This is simply the longest common subsequence of P and Q, which is a known dp.
https://codeforces.me/contest/2242/submission/381527102 E. Let P = 2**k the highest power of 2 <= R. If we can do y = P, we should and x = max(L, P/2). This is because the ones digits of y are multiples of k+1, which is 1, 2, 3, ... modulo k, which is the same order as x. Therefore we just want the smallest value of x that is one less digit (bit-length).
If we can't, then x and y have the same bit-length. Every 1 in the common prefix of L and R must be on x and y, and the rest of the bits will be zero. To attain this, choose x = (common prefix) + 01111.... and y = (common prefix) + 10000....
ahhh! was'nt able to figure out the case where the interval did'nt had any power of 2
Screencast with commentary
Problem B can be solved with the same idea as this problem: https://codeforces.me/problemset/problem/2103/C
Q:D I solved this problem by generating all possible strings using DFS. For every string, I merge one adjacent pair of digits ("i" and "i+1") into (a[i] + a[i+1]) % 10, remove leading zeros, store the new string in a map (to avoid duplicates), and push it into a stack to continue generating all possibilities. I repeat the same process for both input strings and then find the longest common generated string. Is this approach correct? If not, where is the flaw in my logic or implementation?
```cpp void solve() { stack st; string a, b; cin >> a >> b;
st.push(a); unordered_map<string, int> mpp; mpp[a] = 1; while (!st.empty()) { string tt = st.top(); st.pop(); int n = tt.size(); for (int i = 0; i < n - 1; i++) { int val1 = tt[i] - '0'; int val2 = tt[i + 1] - '0'; int f = (val1 + val2) % 10; string str = tt.substr(0, i); str += char(f + '0'); str += tt.substr(i + 2); int pos = str.find_first_not_of('0'); if (pos == string::npos) continue; str = str.substr(pos); if (!mpp.count(str)) { mpp[str] = 1; st.push(str); } } } stack<string> st2; st2.push(b); unordered_map<string, int> mpp2; mpp2[b] = 1; while (!st2.empty()) { string tt = st2.top(); st2.pop(); int n = tt.size(); for (int i = 0; i < n - 1; i++) { int val1 = tt[i] - '0'; int val2 = tt[i + 1] - '0'; int f = (val1 + val2) % 10; string str = tt.substr(0, i); str += char(f + '0'); str += tt.substr(i + 2); int pos = str.find_first_not_of('0'); if (pos == string::npos) continue; str = str.substr(pos); if (!mpp2.count(str)) { mpp2[str] = 1; st2.push(str); } } } int maxi = INT_MIN; for (auto &x : mpp2) { string s = x.first; if (mpp.count(s)) { maxi = max(maxi, (int)s.size()); } } if (maxi == INT_MIN) cout << "-1\n"; else cout << maxi << "\n";} ```
We don’t need to remove leading zeros.
Also, even if you correclty implement your logic, it will still result in a TLE.
I have a question regarding the last problem.
So it's established by now that when $$$n\leq 100\,000$$$, a quadratic solution exists. My solution was essentially "go right to left, maintain the function $$$x\mapsto$$$ how much we'll have in the end if we start with $$$x$$$, we only need to know its values for $$$x\leq 2n$$$, we'll have to do like 3
memcpys every time". But I couldn't squeeze thosememcpy(to, from, cnt * sizeof(int))(it took about 1.6s on my maxtest in custom invocations). I managed to squeeze this solution by making each function value take 3 bytes instead of 4, so that wememcpyless stuff, but do people maybe know how tomemcpyfaster? I found some like intrinsics and stuff blog from @sslotin, is it the best known way tomemcpy?You can bruteforce it without memcpy: 381535935 (thx to jeroenodb for showing me this)
Perfect, it is my first time to join it.I feel funny and I enjoy to solve it
plz release the tutorials soon
Amazing round
How can I become a trusted participant?
for those who are ranting about B it was such an easy greedy just get smallest 1st and 2nd part but yeah remember while getting 1st part if you have more 1s then 2 and 3 and the next no. is 3 inlcude it in your set of 1st part(this was the only idea that was to be thought) ~~~~~
include <bits/stdc++.h>
using namespace std; int main(){ int t; cin >> t; while(t--){ int n; cin >> n; vector inp(n); for(int &x:inp) cin >> x; int cn1=0,cn2=0,cn3=0; int prt1=-1,prt2=-1; for(int i=0;i<n;i++){ if(inp[i]==1) cn1++; else if(inp[i]==2) cn2++; else cn3++; if(cn1>cn2+cn3 && i<n-1){ if(inp[i+1]==3){ prt1=i+1; break; }} if(cn1>=cn2+cn3 && cn1>0){ prt1=i; break; }} cn1=0; cn2=0; cn3=0; for(int i=prt1+1;i<n;i++){ if(inp[i]==1) cn1++; else if(inp[i]==2) cn2++; else cn3++; if(cn1+cn2>=cn3 && (cn1>0 || cn2>0)){ prt2=i; break; } } if(prt1>=0 && prt2>=0 && prt2<n-1) cout << "YES" << '\n'; else cout << "NO" << '\n'; }} ~~~~~
..
Umm can say thatt but yeahh brute force is something that i usually avoid in Problem B max times it is alwayss greedy but yeahh that 3 after 1 thing is kinda difficult to think i agree to that tho Umm tbh after seeing the B problem in last two div 2 contests i was likee that this one is not that difficult because last times were ahh too difficultttt
Problem C was interesting. Couldn't solve D, E or F, though. This CF website looks awesome though, just tried it a few days ago
Another FST T_T, why me (:)|( ಥ_ಥ
When will the editorial get posted? My solution got TLE for $$$F$$$ and I'm so interested to see and read the solution for it...
I am new to this, But this contest was rated right...?
about how long does it take for Ratings to come out?
It has just changed
Is there an issue with rating changes? I think unofficial participants got rated (for example, current div. 2 first place). To be honest, I'm biased since I'm second now but the point stands. Or maybe zhaoyuebo (current P1) registered as rated but is a new account so not counted as trusted but still able to get rating?
Q:C Input: 4 5 1 1 2 2 Output: 0
If I mark and remove the elements at indices 0 and 2, the resulting array becomes [1, 2]. According to the question, after applying the operation, all marks are reset. Then, the element at index 0 is marked automatically. I duplicate all the marked elements, so the array becomes [1, 1, 2]. Again, the element at index 0 is marked automatically, and I repeat the same operation. Continuing this process, the final array becomes [1, 1, 1, 1, 2]-->> according to me output is 1
after [1, 2] you have to mark 2 also, the problem states mark first element and all elements such that a_i != a_(i — 1), so you can either make it [1, 1, 2, 2] or []. Notice how you can keep only even number as the array length, so you can never make 5 out of it.
Am I the only weird one who thought that in D O(NM) would TL because (10^3*5)^2 = 10^7*2.5 and was looking only for linear or smth(that doesn't exist ig)? I hoped there would be more losers like me here at least.
I had the same mistake
.
Am I the only one who came up with this dumb dp for D? 381597490
Appeal regarding automated plagiarism flag for Problem 2242D
My submission [381510406] was flagged for similarity with users Dustu_103 and Debajyoti23je0291.
We are part of the same university group and use an identical base template for fast I/O, macros, and standard shortcut definitions. Because the core logic for problem 2242D is relatively concise, the structural similarity is entirely due to our shared template setup rather than any code sharing or collaboration during the live round.
contest was good only able to do 2
Where’s the tutorial? I need to know E.q_q
they published it.. but didn't update here
https://codeforces.me/blog/entry/155047
please update this announcement post with the editorial link ie https://codeforces.me/blog/entry/155047