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

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

Neapolis University Pafos

Привет, Codeforces!

Благодаря поддержке Neapolis University Pafos, продолжается серия образовательных раундов.

В Apr/03/2025 17:35 (Moscow time) состоится Educational Codeforces Round 177 (Rated for Div. 2).

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Раунд основан на задачах Открытого Чемпионата и Первенства Карелии по спортивному программированию. Если вы участвовали в этих соревнованиях, то воздержитесь от участия в раунде.

Задачи для раунда вместе со мной придумывали и готовили Галина Galina_Basalova Басалова, Валентин Valentin_E Ермишин и Лев robotolev Провоторин.

Хочу поблагодарить авторов задач чемпионата, чьи задачи не вошли в финальный набор для раунда: Руслан r314 Алькин, Юрий basalov_yurij Басалов, Алексей ashmelev Шмелев и Николай Nicola95 Ермолин.

Также хочу сказать большое спасибо координаторам раунда: Ивану BledDest Андросову и Михаилу awoo Пикляеву за улучшение качества задач и помощь с их подготовкой.

Спасибо нашим тестерам: Brovko, deni1000, KIRIJIJI, shnirelman, Alenochka, slash0t, LightSky, infinite_meltdown, Knh_era, M1chail, Antithesis, Kolychestiy, neohacker за ценные советы и предложения!

И конечно, огромное спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

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

Наши друзья из Neapolis University Pafos также хотят передать вам сообщение:

Открыт прием на бакалавриат по программе "Компьютерные науки и искусственный интеллект" в Университете Неаполиса в Пафосе!

JetBrains Foundation поддерживает эту программу, предоставив 20 полностью финансируемых стипендий для талантливых студентов первого курса. Изначально было объявлено о 15 стипендиях, но теперь их количество увеличено до 20, чтобы дать большему числу студентов возможность присоединиться к программе.

Каждая стипендия покрывает весь срок обучения, включая: оплату обучения, проживание, медицинскую страховку, визовые сборы и карманные деньги (300 евро в месяц).

Также теперь доступны 2 полностью финансируемые стипендии для студентов, переходящих на второй год обучения.

Узнать больше →

Первая волна набора:

  • Срок подачи заявок – до 23 апреля 2025 года
  • Вступительный тест – 27 апреля 2025 года

UPD: Разбор опубликован

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

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

Can anyone say me the difference between educational rounds and normal rounds?

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

    Edu rounds:

    • Problems are meant for educational, so the technique is pretty much can be found in textbooks or similar problems in the past.
    • The standings/scoring/penalty will be a little bit different from normal rounds.
    • The difficulty of Edu round usually have the same range as normal Div. 2.
  • »
    »
    14 месяцев назад, скрыть # ^ |
    Rev. 4  
    Проголосовать: нравится +6 Проголосовать: не нравится

    Including minuki's points biggest difference is that there is a 12 hour open hacking phase.

    During this time, you/someone else can attempt to create new, valid test cases that adhere to the problem's logic and constraints, but they can only target and test the code of one other specific participant at a time.

    If a submitted solution fails on one of these newly created test cases (resulting in Time Limit Exceeded or incorrect output), the creator of the successful hack earns points (i think its +100 or something). (UPD: INCORRECT DOESNT HAPPEN)

    After the 12 hour hacking phase, these newly generated test cases are incorporated into the final system testing to identify any other solutions that fail under these conditions.

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

    why rating updation is delayed?

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

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

For most people: classic questions and tricks For me: never seen them before and have no idea about them

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

new writers of Educational Codeforces Round!

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

I hope it goes well.

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

New Era in Edu rounds??

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

non-BledDest edu round?? surprised

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

As a tester, FelixArg [orz] * INF

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

Galina_Basalova why you are newbie

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

I must go to bed before 11:35 pm(UTF+8), should I participate this round?

UPD: I just found that I can participate this round in UNR mode :)

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

When the contest is 45 minutes long:

pE63Ixg.png

It seems very wonderful. Cheaters everywhere.

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

guys i have a problem i can think and solve in my brain problems till 1700 but when it comes to implementing i suffer from lots of bugs i code c++ can somoene help me with this i need to pass newbie phase

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

    Maybe you can turn on Warning All mode.And I write down the bugs I have made and classify them,including bugs on problems understanding and on details.Maybe this will work

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

How to solve E?

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

      damn im dumb

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

      Yeah but how to do it?

      Like how do u know the actual value of k while constructing your number in digit dp?

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

        There will be 30 numbers less than 1e18 which are zebra-like,with a[i]=4*a[i-1]+1. To calculate zebra-value of a number n,iterate from highest to lowest ZL number and if current ZL is higher than number add n/ZL to answer and update n to n%ZL(this is simple greedy).

        Since a[i]=4*a[i-1]+1 for ZL,we can add at max 4 for each ZL,but if we add 4 for a ZL[i] then n becomes 0(n must be less than next ZL[i+1] which is 4*ZL[i]+1 ),so we can add 4 only once,hence max k is 3*30 + 1.

        So,to find count of numbers less than equal to a integer n with zebra value k,calculate contribution of each ZL in zebra value of n ,now iterate backwards from highest ZL to lowest ZL and this is it.

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

    dp digit, although I couldn't do it on time. We can iterate from lower to higher bit, and for each bit in the even position, we try to iterate the number of 1 which will be add in that position. Notice that the number of 1 won't be increase, so we need to store the upper bound of this number each time we iterate.

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

Solved a Digit DP problem for the first time in a live contest, the only issue with the round is difference between (D-E) and (E-F) is too much.

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

b was kind of easy but I wasted time taking x as int and debugging ;(

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

In Problem $$$E$$$, to minimize $$$p$$$ we must write $$$x$$$ in base $$$z$$$ right?

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

Was C that easy or am I dumb?

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

How to NOT TLE in D? I use memorization + recursive (calculate f(odd_remain, even_remain, current_index))

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

I had right mindset in D but i dont why answer was some random no always I hate this MOD kind of questions

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

misread B,and wasted 1 hour,btw all questions that I read(A-D) were nice.Thanks for the contest

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

People who solved F please explain the key logic, coz I'm missing something and its itching my brain.

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

Can someone tell what's wrong in my approach for problem B?

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

editorial when?

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

How to solve D?

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

    Decide , which characters you want to place at even positions (or odd positions) , then the sum of $$$c[x]$$$ corresponding to them must be equal to number of even positions. So just find those ways using knapsack.

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

    Every letter must be all placed in either odd or even place.Then we can DP,the state is the count of letters placed in odd and even places.Let n be the total count of letters,this is O(n^2)

    But if we know the count of odd places,the count of even places can also be known.So the time can be O(26n)

    The transfer is to place all same letters in either odd or even places,this can be calculated by Combination Number in O(1) if we have preprocessed.

    My code

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

someone explain B please

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

Hint for D please.

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

    Get sum of all ci's. now get k which is ceil(sum/2), form subseqeunces of array(remove all the zeros for better understanding) which give the sum as k. for this collections of characters the number of permutation would be=(number of elements in the subseqeunce)!*(number of non zero ci's — number of elements in the subseqeunce)!/(product of factorial of all ci's). do the same for each subseqeunce you get and add them up and mod whatever value they gave. you would need to use dp to get these subseqeunces

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

      although I haven't read your comment but I just wanted to tell that Hint != solution in any dictionary

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

    Every letter must be all placed in either odd or even place.Then we can DP,the state is the count of letters placed in odd and even places.Let n be the total count of letters,this is O(n^2)

    But if we know the count of odd places,the count of even places can also be known.So the time can be O(26n)

    The transfer is to place all same letters in either odd or even places,this can be calculated by Combination Number in O(1) if we have preprocessed.

    My code

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

How to solve d ?? can anyone give the hint

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

    You need to calculate how many permutaions you can to do when you fixed %2 for ever character. And then you can calculate how may combinations of %2 for ever character have (DP). Check my code, if you don`t understand me.

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

    For any valid distrbution of char (ex: 'a' in odd postion, 'b' in even position, ...), the number of sequence are the same.

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

      • Each letter must be placed entirely in even or odd indices.
    • Total Positions:

      • Let n = sum(c[i]) be the total string length. assume 0 indexed string.
      • Define E = ceil(n/2) (even positions) and O = floor(n/2) (odd positions).
    • Subset Sum Condition:

      • We must choose a subset of letter counts summing to E (remaining letters go to O).
      • Use dynamic programming (DP) to count valid selections.
    • Once an assignment is fixed:

      • The even positions can be filled in: $$$\frac{E!}{\prod_{i \in \text{even}} c[i]!}$$$
      • The odd positions can be filled in: $$$\frac{O!}{\prod_{i \in \text{odd}} c[i]!}$$$
      • Combined, the total permutations for any valid assignment are: $$$\frac{E! \times O!}{\prod_{i=0}^{25} c[i]!}$$$
    • Since this value is independent of specific assignment:

      • we multiply it by the DP count X (number of valid ways to distribute letters).
    • Final Answer $$$= X \cdot \frac{E! \times O!}{\prod_{i=0}^{25} c[i]!}\mod998244353$$$

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

    Every letter must be all placed in either odd or even place.Then we can DP,the state is the count of letters placed in odd and even places.Let n be the total count of letters,this is O(n^2)

    But if we know the count of odd places,the count of even places can also be known.So the time can be O(26n)

    The transfer is to place all same letters in either odd or even places,this can be calculated by Combination Number in O(1) if we have preprocessed.

    My code

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

I think it is good problems. But i think, task D is very easy for his place. And I can`t understand, why so many people OK C on very low time?

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

So many cheaters again. So sad this is the closest shot I got at becoming master and I am probably going to lose it because of cheating :(

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

For problem D, I was going with an approach where I needed to apply subset sum algorithm. Looking at the constraints it seemed fine.

This is using recursive memoization approach https://mirror.codeforces.com/contest/2086/submission/313827623

On the other hand this is using iterative dp https://mirror.codeforces.com/contest/2086/submission/313827274

The recursive approach gave a TLE at testcase-2 whereas iterative got accepted. Never seen such a case and I am more comfortable with recursive dp so always prefer it. Any idea why it failed?

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

For problem D, I was going with an approach which needed me to apply subset sum algorithm.

I went with recursive memoization approach and this is its code https://mirror.codeforces.com/contest/2086/submission/313827623

The below is the iterative dp approach for it https://mirror.codeforces.com/contest/2086/submission/313827274

The problem is that recursive method gave a TLE at testcase-2 whereas iterative approach passed all the cases. I always prefer writing dp in recursive method since I find it comfortable and have never faced this issue in any other contest.

Anyone has any idea on whats going on?

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

Number 1 in Div.2 (jack_l_b_b) is using AI right? Compilation error in A, then submit a code like this for A:

long long n;
cin >> n;
long long berries_needed = 2 * n;
cout << berries_needed << "\n";

I mean, to print 2 * n like this, and solve it in 6 minutes, I bearly think that his rating would be >1500. After that, this user spends only 5-9 minutes on B to E, with over 100 lines of code for submissions for D and E. Also, the format looks like GPT-written with comments washed out only, and the variables are too long for a human to use.

P/s: I just posted this in a post, but it is removed. The problem of today's round is great, especially F amazing task which I'm so looking forward to reading the editorial. It's just that it is really possible to use AI and get 1st place...

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

This was my first contest, I was able to do A and B and like almost C. Overall I think I did pretty well, but then how are 7k people solving the third one? do people cheat in the contest here? also when will I get my first rating?

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

There's even a Youtube channel that live solved the problems during the contest !!

Link : https://www.youtube.com/live/4_z0spfV_pM?si=LuEVWNSrDAozlBk9

How shameful!!

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

niggawhat

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

damn it! I finally got fucked up by memset, I mean D.

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

For D, if I use ll dp[sum+1][27], it gives me SIGSEGV in my vs code(seg fault) but when I use vector<vector > dp(sum + 1, vector(27, 0)), it passes, any proper reasoning to it, as the max value of sum is given to be <= 5e5, unable to get the reasoning behind it. Please help.

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

Isn't problem A ridiculously easy even for a Div 2 A problem?

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

I noticed that some of the cheaters got live removed, however, there are still a lot of suspicious accounts which should be investigated further, e.g. in the top 5: chenzheyuan, hprwhgsafwan12, not.found

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

Cool man found! I think StarSink cheated.

StarSink's code in B C D E has tons of annotation. WOW! Even more than the codes?

And you can see the solving time is random and funny: 01:30 01:51 01:26 01:25 01:49.

D used 1:25? That doesn't matter, maybe he forgot the contest?

Why C only 1 minute?

Then Finally A?

A used 5 minutes?

Then, E??? Why not B?

B in 2 minuets???

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

How is D implemented? I think i have the idea.

  1. |i-j|%2 = 0 => all occurrences of a character should be stored either in odd/even position
  2. Now ways to arrange them is : number of ways to chose x1, x2, .. xn such that f[x1] + f[x2] .. f[xn] = n/2 where x1, x2.. are characters and f[xi] represents their frequency. and number of permutations for each one is (n/2)!/x1!*x2!...xn!.. The ans is 0 if no such combination exists. Use knapsack. The issue is: I have no idea how to implement this efficiently. Can you guys help?
»
14 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

For problem D, an ungraceful solution is just dp without using combination of multisets, set f[i][j][0/1] as the number of ways to fill, now is the i character, has filled j chars in odd positions, now char filled to odd/even position, we can use prefix_sum to calculate numder of filled even position as every char must be filled, then use C(remain position, c[i]) to multipy previous number of ways. https://mirror.codeforces.com/contest/2086/submission/313862304

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

Problem D was educational, sure, and that's the reason it was easily solved by AI.

It's sad to know that cheaters might have gotten through this problem like this anyway.

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

Does this round become unrated? (my screenshot)

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

When Editorial?

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

2086E - Zebra-like Numbers depends on the observation that

Spoiler

Is there a simple proof of this property?

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

For problem D, my solution was as follows:

First, since the indices need to be a distance apart that is equivalent to 0 mod 2. We can split the indices into red and black squares, like a chessboard.

For each valid partition, there will be a black group and a red group, and the sum of the black group will need to be ceil(n/2) and the sum of the red group will need to be floor(n/2) where n represents the total length of the string

Each valid partition can then make up multiple valid orders. The amount of valid orders of each valid partition is the product of the multinomial coefficients of both groups.

To find the valid partitions you can use iterative dp or recursion with backtracking. I used the recursive method since it was more intuitive.

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

Разработчики раунда лучшие!

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

The developers of the round are the best!

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

Why is the round still unrated for some people?

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

Yeah.I solved 5 problems in this contest and get purple now ^_^

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

i received a warning, for my solution coinciding with solutions with A LOT of users, i do not know why others have similar solution as me, it said to comment on this post to appeal i guess? the only proof i wouldve had were my failed attempts on vs code, but this was weeks ago so i cant access that-

but like if i am to explain my approach and code,

i basically tracked the group elements which resulted in loop/cycle and separated them

cyclecount was basically index of the loop, so tell that this element was in this loop, and i kept track of the loop length, and then basically add lengths of all separate groups.

if theres anything else i need to clarify lmk