Блог пользователя BledDest

Автор BledDest, 2 месяца назад, По-русски

Neapolis University Pafos

Привет, 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. Спасибо за помощь в подготовке контеста!

Удачи в раунде! Успешных решений!

  • Проголосовать: нравится
  • +111
  • Проголосовать: не нравится

»
2 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

I will be live with post contest discussion stream here

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As an sc3developer, hope my computer doesn't fall into a bottomless pit this round

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

wow!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Why not "6 or 7 or 67 problems" this time?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Letsss Go...

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Good luck to all participants!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Good luck to all participants!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Time to get humbled by c again. -:lol:-

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

If it's Neapolis we cooked again

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Ahh another edu... goodbye purple

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Ahh another edu... goodbye purple

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Do you guys recommend a unrated guy to join?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится -33 Проголосовать: не нравится

.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

yay, another contest! lets have fun!!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

Fight for Master go go go

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

yes, good luck to all participants!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

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

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

i need to find the guy with tnt pfp

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Thanks for the round! Good luck, everyone!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Good luck!!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Good luck!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I love problem C.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

seven submissions for last problem

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As a graytist (graytist != ratist btw), nooo I'm getting back to newbies after this round.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

3k solves for D is crazy

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can F be solved with persistent treaps?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

$$$A, B, C$$$ were kinda standard, as expected for a Educational round. But $$$D$$$ was a good problem!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

D is a cool problem, sad that I solved it 3 minutes before the contest ended

»
2 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

so close to solve c, wasted a lot of time on b, i dont know why :(

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

D is a nice DP problem!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Damn, i bugged my solution for C but still, great contest!

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

got 3 minute late to submit E!

  • »
    »
    2 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    how to solve D?

    • »
      »
      »
      2 месяца назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +4 Проголосовать: не нравится

      My whole thought process & solution for D.

      Spoiler

      code: 381515191

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

B was a disaster

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

:-(

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

wasted 1 hour thinking constraint was 1e5 for both the strings in D :((

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    2 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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

    • »
      »
      »
      2 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Ohhh i get it, then i do use that fact XD Thank you!

    • »
      »
      »
      2 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      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

      // unique occuring sorted frequency ;;; 
      // occurence[x] -> how many times x or greater element occurs ;;
      // exact-> exactly this frequency occurs this many times 
      
          int ans = 0 ; 
          FOR(i,0,sz(freq)) 
          {
              int diff = n - (occurrence[freq[i]] * (freq[i] -1) ) ; 
              int aim = k ; 
              
              aim -= diff ; 
              if(aim % occurrence[freq[i]] == 0) ans ++ ; 
              n -= (exact[freq[i]] * freq[i])  ;
          }
      
      

      Thanks for your time , really appreciated ;;

      • »
        »
        »
        »
        2 месяца назад, скрыть # ^ |
        Rev. 2  
        Проголосовать: нравится 0 Проголосовать: не нравится

        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

  • »
    »
    2 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

The problem F made me get Master!

»
2 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

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....

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится
»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem B can be solved with the same idea as this problem: https://codeforces.me/problemset/problem/2103/C

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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";

} ```

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

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 those memcpy(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 we memcpy less stuff, but do people maybe know how to memcpy faster? I found some like intrinsics and stuff blog from @sslotin, is it the best known way to memcpy?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Perfect, it is my first time to join it.I feel funny and I enjoy to solve it

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

plz release the tutorials soon

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Amazing round

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How can I become a trusted participant?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится -9 Проголосовать: не нравится

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'; }} ~~~~~

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

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

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Another FST T_T, why me (:)|( ಥ_ಥ

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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...

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I am new to this, But this contest was rated right...?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

about how long does it take for Ratings to come out?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    2 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

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.

»
2 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Am I the only one who came up with this dumb dp for D? 381597490

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

contest was good only able to do 2

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Where’s the tutorial? I need to know E.q_q

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

please update this announcement post with the editorial link ie https://codeforces.me/blog/entry/155047