Автор awoo, история, 3 года назад, По-русски

Привет, Codeforces!

В 29.06.2023 17:35 (Московское время) состоится Educational Codeforces Round 151 (Rated for Div. 2).

Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

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

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

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Иван BledDest Андросов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

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

Также от наших друзей и партнёров из Harbour.Space есть сообщение для вас:

Harbour.Space
НОВАЯ ВОЗМОЖНОСТЬ ОБУЧЕНИЯ И РАБОТЫ В БАРСЕЛОНЕ — IDS x HARBOUR.SPACE UNIVERSITY

Intentionally Designed Solutions (IDS) в партнерстве с Harbour.Space University предлагают стипендию для получения степени магистра в области Frontend Development, а также опыт работы в качестве Frontend-разработчика в ведущей студии разработки продуктов, специализирующейся на веб-решениях, включая веб-сайты и веб-приложения.

Все успешные кандидаты будут иметь право на получение стипендии со стопроцентной оплатой обучения (22 900 евро в год), предоставляемой Intentionally Designed Solutions (IDS).

ОБЯЗАТЕЛЬСТВА КАНДИДАТА

Обучение: 3 часа в день

За год обучения вы завершите 15 модулей (длительность каждого 3 недели). Ежедневная учебная нагрузка составляет 3 часа, плюс домашнее задание, которое нужно выполнить в свободное время.

Работа: 4 часа в день

Погрузитесь в профессиональный мир во время обучения. Вы будете учиться у лучших и с первого дня сможете применять свои новые знания на практике.

ОБЯЗАННОСТИ

  • Сотрудничество с многопрофильными группами для разработки и внедрения инновационных решений, соответствующих проектным требованиям и спецификациям.
  • Написание чистого, эффективного и удобного кода с использованием современных технологий, включая Typescript и Svelte.
  • Обеспечение плавной интеграции front-end компонентов с back-end системами, используя такие технологии, как MongoDB и Firebase.
  • Демонстрация базового понимания технологии смарт-контрактов, позволяющей интегрировать кошельки и функции блокчейна в веб-продукты.
  • Руководство и наставничество младших разработчиков, проведение разборов кода и предоставление рекомендаций по улучшению качества кода и практики разработки.
  • Управление направлением развития бизнеса IDS путем выявления возможностей для оптимизации процессов, повышения эффективности и повышения общей производительности команды.

ТРЕБОВАНИЯ

  • Минимум 2 года профессионального опыта в разработке, с акцентом на веб-продукты.
  • Высокий уровень знания Typescript и Svelte, а также хорошее понимание front-end фреймворков и библиотек.
  • Опыт с внутренней интеграции, особенно с MongoDB и Firebase.
  • Базовое понимание технологии смарт-контрактов и ее применения в веб-разработке.
  • Предыдущий опыт управления и наставничества разработчиков, проведение разборов кода, и улучшение процессов разработки.
  • Отличные навыки решения проблем, общения и сотрудничества.
  • Степень бакалавра или эквивалентный опыт.
  • Продвинутый уровень английского языка.
Подать заявку →

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

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

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

As a green participant, I hope to be cyan again after this contest)

If you want to race

GL & HF

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

as codeforces user i hope to have great round

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

Again no tester

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

big chance to become green tomorrow

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

The road to green, God willing

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

Will "not rated participant" get rated in this contest?

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

I want everyone to take it to the next level

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

I want everyone to take it to the next level

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

Why can't the code submitted now be viewed on the PC side?

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

who tested this round?? who tested this round?? who tested this round?? who tested this round??

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +12 Проголосовать: не нравится
    I think
  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +18 Проголосовать: не нравится

    Nice contest, but there's just one small problem with it: who tested? like genuinely who tested? who gave you the testing code? I'll tell you nobody did, nobody tested it. There are zero people who tested among us, look I invited everyone who tested to this party, and took a photo of everyone who tested, yo check out it's a bus full of everyone who tested. You know what man, I'll do you a favor, clearly we can't see who tested, so I'm just gonna do it myself, I'm gonna find out who tested. I sailed in the seven seas to find out who tested, yo I literally found the one piece before I found who tested, I literally climbed to the top of Mount Everest and didn't find who tested. Keep searching boys we gotta find who tested. I just infiltrated the largest satellite dish in the world and I still can't locate who tested, I literally found the cure to cancer before I found who tested, I'm on maximum render distance and I still can't find who tested, I witnessed the collapse of human society resulting from a global nuclear war, I now live in the grave of this broken world ravaged by radiation for years on end before I found who tested, I visited every single planet in no man's sky and still didn't find who tested, doctor strange literally looked through 14 million different timelines and not in one of them than anyone tested, I literally searched through every single backroom's level and didn't find who tested, I literally died and went to heaven and god himself doesn't even know who tested. Leaving the earth's atmosphere to expand the range of our search, yo I literally found extraterrestrial life on Mars before I found who tested, I have achieved intergalactic travel before I found who tested, I just found a dyson sphere before I found who tested, I found the edge of the universe before I found who tested, I literally visited every single planet in the entire universe before I found who tested, I am literally witnessing the death of almost every star around me before I found who tested, the light of the universe is slowly fading I have searched across galaxies leaving no stone unturned, yet I am afraid my time in this universe is finally running out, it's a shame really I've witnessed stars being birthed and those same stars dying, I've seen literally everything there is to see in this beautiful universe, yet this whole time I've been caught up with such a petty task instead of enjoying my time while it lasted. I was distracted from the beauty of it all I don't regret what I've done, though the question that started it all: who tested has finally been answered. I've searched every nook and cranny in this entire universe and can now confidently say better than anybody that truly nobody tested [Music] the contest.

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

As a cyan participant I hope to go green this round.

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

What's the difference between common round and Educational round?

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

As a blue participant, i hope to cross my peak rating :)

GL & HF

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

Maybe I am ready to take the next step.

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

Problem C was really something..

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

any hint D please

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

how to do C with binary search?

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

Can someone give a hint on E please?

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

    You can squeeze in $$$O(NK^2)$$$

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

      I was thinking about something like doing a dp which keeps track of three parameters: current idx (n), current one, and wasted moves

      would this work ?

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

        This would, trivially implementing this is $$$O(NK^2)$$$. To squeeze it in, you can do the following: 1. If more than half of the array are $$$1$$$-s, you can consider that every box without a ball has one, and vice versa. This halves the runtime. 2. Write out the formula: $$$dp[i][k][p1] = dp[i - 1][abs(k - pos[p1 - 1])][p1 - 1]$$$, where $$$i$$$ is the current position, $$$k$$$ is the number of wasted moves, and $$$p1$$$ is the number of wasted moves so far. Notice that you can keep this dp in a single array and recalc top to bottom, so you do not do memsets and swaps.

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

    How far did you get/what part of the problem do you want a hint for?

    I think there are several stages in solving this problem:

    1. Thinking of any solution at all (this one you should probably do by yourself).
    2. Realizing how to make it run in $$$\mathcal{O}(N×K^2)$$$.
    3. Realizing how to optimize it into $$$\mathcal{O}(N×K^{1.5})$$$.
    4. Making the implementation efficient enough to fit in the time/memory limits.

    (I failed at step 4.)

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

How many people solved Problem C, ** AFTER READING SECOND TESTCASE DATA in TESTCASE 1 ?**

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

How to do D?

My intuition was maximizing this, pref_sum [i] + max(suff_sum[i + 1], ..., suff_sum[n — 1])

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

explain solution for C?

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

    I bootled this so bad . I got accepted after 7 minutes of contest end , the idea is so easy i just messed up the implementation :

    idea is that after you choose a number the first occurrence of that number splits the string into two, now the problem reduces to the right half only . so we can greedily choose the number from possibilites (that is between l[i] and r[i]) which gives the shortest possible remaining string. If at any iteration (i) one of possible numbers is not in the remaining string choose it and that gives answer yes. If you finish traversing all i's without then the answer is no.

  • »
    »
    3 года назад, скрыть # ^ |
    Rev. 11  
    Проголосовать: нравится 0 Проголосовать: не нравится
    Spoiler
  • »
    »
    3 года назад, скрыть # ^ |
    Rev. 7  
    Проголосовать: нравится +1 Проголосовать: не нравится

    Start from last in both range strings(l and r) and string s, let say p1 = n-1, and p2 = m-1.

    Now, looking from last (i.e from p1 to 0), find the numbers in range l[p2] and r[p2], if at any p1, you find all the numbers in the range, then reduce p2, then again find all the numbers in range l[p2] and r[p2], do this until you will encounter one of the case, if p1 becomes -1, then that means you can make some password which will not be subsequence in string "s" therefore the Answer would be "YES", else p2 would have became -1, that means all the ranges have ended therefore all the possible subsequences are present in string "s", Hence the Answer would be "NO".

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

Yet again I misread a problem, this time C. I thought it was asking to check if there exist a string s, such that s >= l && s <= r, instead of s_i >= l_i && s_i <= r_i. (mathjax not working?)

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

Overkilled D with binary search and sparse table and now feel very annoyed at myself. :(

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

    How did you solve D with binary search and sparse table? I am curious to know. My technique used a modified version of kadane's algorithm to solve it.

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

      Fix the position of k then find the smallest subarray starting at that position that has negative sum. Rating will be k after that. Repeat until there is no more subarray with negative sum. Rating at the end will be k + suffix sum from there. To simulate the above process run a binary search for the first index where sum of subarray starting at k's index is negative. Sparse table helps here. Yes it's overkill. And it's basically the same idea

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

D is a neatly disguised minimum subarray sum problem

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

How to do E? I have a O(n^2 k) DP which TLEs. Is this the intended solution, or is there anything faster?

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

    is it dp[i][j][p] = how many possible placements are there if the ith ball is at jth position and we have used p swaps so far

    in the end answer is =

    for(int j = 0 ; j < n ; j++){
    	for(int p = 0;p<n;p++){
    		if((k - p) % 2 == 0)ans += dp[n-1][j][p];
    	}
    }
    

    ( I just asked this to confirm if my idea was correct )

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

    I used the fact that if $$$one_i$$$ is the position of i-th one, possible final positions for i-th one are roughly $$$[one_{i-\sqrt k}, one_{i+\sqrt k}]$$$. If you use this then there is only $$$O(n\cdot k^{1.5})$$$ states.

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

    Congratulations for coming up with the $$$O(n^2k)$$$ DP! My solution is simply an optimization of the $$$O(n^2k)$$$ DP and the time complexity is $$$O(nk\sqrt k)$$$.

    In one word: throw away all useless states.

    In more words:

    DP is deciding from the left to the right for each position whether to put a 0 or 1 and count the number of inverse pairs (aka number of swaps used). Let DP[i][j][p] be the number of situations that: we have already decided the first $$$i$$$ positions, among them we have used $$$j$$$ 1s and we have encountered $$$p$$$ swaps. Naive implementation of this DP is $$$O(n^2k)$$$, but a state is useful only if $$$\left|j-S_i\right| \lt = O(\sqrt k)$$$ (where $$$S_i$$$ is the prefix sum of the original array), otherwise the number of swaps will be too large ($$$ \gt k$$$).

    Source: Trust me. I am gray.

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

Can any one explain to me why my B submission is not working?

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

Did 3D DP for C worked for anyone?

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

The gap between question D and question E is too big, but of course, it could be mainly because I am too weak. Let's do better next time, although I am still a little disappointed.

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

I overkilled C with DP and I don't feel good now Submission

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

Can't think of any approach for C? Someone please provide some sort of hint like in which direction should I think?

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

can anyone share their greedy/binary search approach for C?

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

    Sure, to solve it using greedy approach, one might try to think of how to build a string that would not be a subsequence.

    To do so let's think of positions of possible values of first digit of resulting password. It definitely should be from l[i] to r[i]. For all such digits let's find their first positions in the string. I claim that it is always beneficial to take digit with maximum value of first appearance. Why? Well, because it destroys more possible subsequences (since we cut off the largest prefix by doing so). See my submission for more details: 211498000

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

      I understood your approach but could you please tell me what this line does?

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

        Of course, for pos[d] I store indexes where digit d appears in s (in reverse order). Now, when I try to greedily build this “bad” subsequence I interpret first appearance of digits as a candidate that can now become new digit of resulting password. When I have chosen this new digit, I know its position in s (it is p), so for all digits from 0 to 9 I want to stop considering ones which happen to have positions <= p.

        Storing in reverse order is very beneficial because it let’s me to delete element from a vector in O(1) and resulting complexity of solution is O(n + 10 * m)

        Hope this helps

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

Haha, I sucked, couldn't solve D.

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

Can anyone share their approach for D?

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

    just find the largest decreasing subarray of input and avoid it, then we get the maximum rating

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

    Let's denote prefix sum to position $$$i$$$, by $$$pref[i]$$$. If you think about it a little, it's easy to see that answer must be in $$$pref$$$ (unless there is no positive value in $$$pref$$$). Let's say that our initial answer is 0, and iterate over $$$pref$$$. Assume that before position $$$i$$$ we found some answer $$$x$$$. Now, we have to find some conditions to determine if it will be optimal to change our answer $$$x$$$ to $$$pref[i]$$$. Surely, it won't be optimal, if $$$x \gt pref[i]$$$. Otherwise, let's denote the prefix sum to position $$$i$$$, if $$$x$$$ was the threshold by $$$pref\_ans$$$. If there is some value $$$min\_val$$$ in $$$pref[i]$$$ on positions $$$[i+1, n)$$$, such that $$$min\_val + (pref\_ans - pref[i]) \lt pref[i]$$$, then it will surely be optimal to change our answer to $$$pref[i]$$$ (because if $$$x$$$ was our answer, prefix sum here will fall below $$$pref[i]$$$). Otherwise it won't.

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

Does someone knows if in problem E, DP with cost $$$O$$$($$$n^2$$$$$$k$$$) is hackable, I got TLE :/ 211505619, but I have seen some AC 211506794 or 211522102

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

Anyone did D by binary search???

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

sorry but problem C statement was poor. you should have highlighted "i-th digit of the password has to be between li and ri, inclusive" with a bullet point :'3

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

Was c really that easy or I guess i am too dumb as 4k people solved it

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

sorry but problem C statement was poor. you should have highlighted "i-th digit of the password has to be between li and ri, inclusive" with a bullet point :'3

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

Problem B, why is the answer to this 1 and not 2 ? 1

1 100000000

1 99999999

1 2

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

Any good hint for E, please? Want to solve it myself

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

Anyone else who felt that D was easier than C?

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

Can someone explain what is wrong with this solution?

It is failing for following in online judge but is working in my local machine: 1 2 1 99999999 1 1

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

    You're adding an additional 1 after 2nd if case.

    if(xc <= 0 and yc >= 0)
        ans = min(yc, yb);
    else if(xc <= 0 and yc <= 0)
        ans = 1; // <------- it should be 0
    else if(xc >= 0 and yc <= 0)
        ans = min(xc, xb);
    else
        ans = min(xc,xb)+min(yc,yb);
    cout << ans+1 << endl;
    
»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Any hints for E?

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

Problem E when I do rolling table using two 2d arrays : oh no !!!, you are too slow !!!, get TLE

Problem E when I do the same rolling table using one 2d array by clever variable saving and iteration : Congratulations !!!, you are accepted !!!

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

It's kinda strange but in E the small trick with changing all zeros with ones and ones with zeros, if the number of ones if more than half, works and makes O(n^2*k) solution pass. I think it's strange and if it's not the intended solution, time limit should be smaller. 211535929

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

What do you guys think is the rating of problem C and D?

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

any anyone share approach for D?

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

can anyone share approach for D?

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

Why is this solution showing MLE in pypy3? I was shocked by this. It's AC in C++ Link: https://mirror.codeforces.com/contest/1845/submission/211534174

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

I'm so dumb that after reading the statement of C, I thought it is digit dp and waste for an hour to write. Then I realized it does not require to make the password from l to r(like 40 to 50 I thought they were 41,42,43...), it is just in range, digit by digit. I solved by the way, but it still got me negative delta. Hopefully for better luck next time :((

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

Problem C ... Can anyone tell me how the answer here is "yes"

s = "01342104424232424004113131423112311240" ,,,,
m = 5 , l = 23004 , r = 24244

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

I hate how non intuitive problem D is. I am still not able to convince myself how the prefix sum just behind the minimum subarray is the answer.

Edit: Got it now. If we choose k = prefix[i] and if there exists a j(>i), such that prefix[j] is the smallest among prefix[i+1...n], then the elements from i+1 to j would contribute effectively nothing to the ratings.

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

    exactly, can someone share how they reached this conclusion and their thought process during solving the problem?

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

      After you fix the prefix sum till index $$$i$$$ as the current $$$k$$$, you can keep adding elements to your current sum until it dips below $$$k$$$.

      This will be when the sum starting from index $$$i + 1$$$ just becomes negative, which is when the prefix sum becomes less than $$$pre[i]$$$.

      Since we can't go below $$$k$$$, we just stop at $$$k$$$. This means we just ignore this subarray and do this process repeatedly: find the next index where the prefix sum is less than the same at our previous position, ignore it (since the subarray sum will be less than zero) and set that as the new position.

      If no index has prefix sum less than that of our current position, our subarray can be extended till the end of the array since the sum will be positive. This will occur only at the minimum of the prefix sum array (let us call this index $$$mn$$$).

      So, the answer when $$$k = pre[i]$$$ will be $$$pre[i] + pre[n - 1] - pre[mn]$$$ (or just $$$pre[i]$$$ if $$$i \geq mn$$$).

      So, the maximum value of this expression will obviously be $$$\max_{i \leq mn} (pre[i]) + \max(0, pre[n - 1] - \min_i (pre[i]))$$$.

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

    I solved this question and I still don't understand the intuition behind it.

    Here are some less complex observations for problem D :

    1. Let's make a prefix array first. Now, our answer is definitely from one of the values in the prefix array.(or 0 if all prefix values are -ve). Why? cuzz we won't let our rating fall from a point where we reached , so out k must be a value we reached.

    2. We can calculate answer for each prefix value (though it's easy to prove that optimal value is always a local maximum).

    3. Begin traversing the prefix array now how to calculate the answer from this value of k = prefix[i] ? ---> Answer is : [ Σa_i + (maximum distance you go below from k in you prefix array) ]

    How to prove this ? ----> You can think of it as : When you add something -ve that takes your prefix value below the threshold k, you actually add some EXTRA to your answer to keep it fixed at value k. Hence , whenever next time when again prefix value goes below k , again add value to EXTRA to keep it at k. Finally you will notice you added total EXTRA = max(0 , k — min(pref[i])).

    --> min(pref[i]) is minimum prefix value that we reached.

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

      Thanks for the explanation, I tried to do something similar by fixing the answer as any one of pref[i] values. Then I calculated the max rating possible when k = pref[i] by adding all +ve values after arr[i] to k, since the rating won't go below k. However where this goes wrong as you might have guessed is that if I fixed k as threshold from the start the rating would not be k when I reach arr[i]. Is that where the (maximum distance you go below from k in you prefix array) in your solution comes into play? I still do not understand what Σa_i is tho, could you please clear that?

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

    I did this for every i, k = prefix[i]; resulting score = prefix[n] + max(0, prefix[i] — min(prefix[i + 1]....prefix[n]))

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

I had a weird idea for C, for a password to not be a subsequence there must exist two indices in it for which it's not possible to get a subsequence from the database, we can brute force for the indices and the possible numbers on them, if these values are indeed the pair of two indices, then either all the occurrence of one is left to the other or this indices maybe belong to the the first m and last m of the database, pretty weird I know :p, someone thought something similar? This is idea, I don't know if it works

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

    WHAT I DID STARTED WITH INDEX POINTER 0 NOW I TRAVERSE THE L AND R STRING FROM STARTING FOR EVERY DIGIT (0 , 9) IN [ L[I] , R[I] ] FOUND THE MAXIMUM INDEX IN MAIN STRING THEN SHIFTED THE INDEX POINTER TO MAXIMUM

    IF NO CHAR IS PRESENT IN MAIN STRING — > HENCE NO SUBSEQUENCE CAN BE GENERATED -> "YES"

    PS : TC 2 HELPED A LOT :)

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

My idea for E. No idea if it's correct or not:

  • So first we notice that parity of the sum of position of 1 changes if k is odd. Other wise it doesn’t change
  • So we make it dp i,j,bool We will now try to take the ball at ith moving left or right. And ball ith can only be at jth if dp[i][j][bool] has some way to arrange. So once we have dp i,j,k, we can see that the balls occupying before pos i can be anywhere between its initial position and i-1 if we know the parity of the left over k from dpi,j,bool
  • We also need to compute the min cost and whether it is possible to move ball i to some position j, because it will shift everything on its way
»
3 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My C binary Search Solution Just greedy for every index, find max index occurrence from l[i] to r[i] and update the maxIndex as the max Occurance you find, do this until for a particular index you didn't find any occurrence greater than maxIndex, if this condition is met then the answer is yes, else no Solution

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

why cant D be solved using Ternary search ?

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

Please anybody give me hint in D problem. I don't know why am I getting wrong answer. Submission --> 211537213

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

Any traders realized that D was just maximum drawdown in your average backtest haha?

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

what is the test that hacks problem a?

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

Please implement same rating system as problem D here too. I don't want to go below expert.

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

what should be correct output for this test case in problem C

1
805544605628
1
7
3

if correct answer is "NO" then please explain me why

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

Worst E question I have ever seen!..

If it has a solution better than $$$O(N*K^2)$$$ that I cannot be able to find then it is okay but if the original solution is to make optimizations on $$$O(N*K^2)$$$ then it is really bad!

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

Can someone give a hint to solve D using Binary Search?

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

Here's an O(N^2K) solution to E that passes in 655 ms. submission

There are no optimizations other than the fact that if more than half the array is ones, you can swap them with 0s. This reduces the solution by a factor of 2.

The original solution (without the optimization) passes in around 3000 ms

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

I don't think an E-question that blocks time is meaningful.

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

Is it possible to solve D using ternary search ?

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

When will there be a tutorial? Or do you already have it but I didn't see it? 什么时候会有教程?或者说已经有了只是我没有看见?

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

Very Important I am a Newbie — @787. Yesterday I solved one question in the round successfully but my rating remained as it is. Why my rating did not increase even on solving one question

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

does anyone know why my ranking did not change even after solving the C problem?211519289

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

Easy Solution for C: 211519289

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

Hacks:

A: WA: 665; RT: 1; TL: 1; ML: 1.

B: TL: 2.

C: TL: 85; WA: 2; ML: 1. [An uphack to C (TL) has been counted.]

D: TL: 14; WA: 3. [An uphack to D (WA) has been counted. ]

E: TL: 2.

F: (None.)

Total: WA: 670; TL: 104; ML: 2; RT: 1.

Count: 777

Could anybody explain why there are so many hacks?

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

Why was problem D so easy?

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

So many Cs and Ds were hacked via TLE. Please explain how to get a code to give TLE. I tried larger inputs, but the system constraint is that input can't be bigger than 256kb. So I could only make use of some of the input constraints.

It can be done using generator, got it now. Sorry for naive question, I'm new to hacking.

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

I guess the idea of problem c was taken from https://cses.fi/problemset/task/1087

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

My submission was having an indexing issue in all cases. Still it passed during contest. But it gave RE on test 3 in system tests. Fixing the indexing issue gave AC.

Why it did not RE during contest?

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

For Problem D, I have tried binary search on answer. I'm getting WA on test2. please can someone help me rectify my code. 211583193

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

    I don't think the answer k satisfies some requirement to apply binary search. Assume the right answer is k, then 0 and inf will get lower rating than k. It is at least a single peak function that cannot apply binary search. By the why, I guess it cannot be solved by observing the rating's pattern of different ks. I solved it by trying all possible ks that can be the answer. There are only O(n) candidate ks and it is small enough to pass the problem D.

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

When got my rating up?

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

update rating when??

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

Problem C can anyone please explain the approach to get position of ith element in string using 2D vector nxt, is there a name for this approach , coz i have seen such code many times. submission:https://mirror.codeforces.com/contest/1845/submission/211443935

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

    Your link isn't accessible by the way.

    How I visualized it is like this: consider first the $$$m=1$$$ case. Obviously what we do is check every digit $$$d_1$$$ between $$$l_1$$$ and $$$r_1$$$. If $$$d_1$$$ does not appear at all in the string $$$s$$$, then we output "YES" because $$$d_1$$$ will definitely work. Otherwise if no such $$$d_1$$$ exists then there is no viable value for $$$d_1$$$, whence we cout "NO".

    Now let's try the $$$m=2$$$ case. For the first digit $$$d_1$$$ we do the exact same as above, but this time even if every possible $$$d_1$$$ between $$$l_1$$$ and $$$r_1$$$ appear, we might still be able to generate a valid passcode if $$$d_2$$$ doesn't appear in the string $$$s$$$ after $$$d_1$$$ does. To maximize the possibly of this happening, we will try to pick the first occurrence of $$$d_1$$$ to be as far right as possible, so that there is less digits of $$$s$$$ that can block $$$d_2$$$ from succeeding.

    But how do we do this? The $$$\mathbf{nxt}$$$ array is what comes into play here. Let $$$\mathbf{nxt}$$$ be a $$$10$$$ by $$$|s|+1$$$ array such that $$$\mathbf{nxt}[i][j]$$$ is the (1-based) position of the next occurrence of the digit $$$i$$$ after position $$$j$$$ in $$$s$$$, or INF if no such position exists. (Long sentence, sorry.) Then the algorithm will be something like this:

    j = 0 // initially we start having no digits of s covered
    for every d1 from l1 to r1
        if nxt[0][j] is INF // then we are done!
            print "YES" and finish
    
    j = max {nxt[d1][j] | l1 <= d1 <= r1} // jump as far right as possible
    for every d2 from l2 to r2
        if nxt[0][j] is INF // then we are done!
            print "YES" and finish
    
    print "NO" and finish
    

    This now obviously generalizes to any positive $$$m$$$, I trust you can carry on the analysis from here :)

    edit: minor typos, sorry

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

As ratings have been updated and hack phase has ended, when editorial?

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

Very Less Rating change for me :(

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

Can anyone explain me dp approach of problem c

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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


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

[DELETED]

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

Can someone please give complete , easy to understand explanation of Problem E explaining it in easier steps , it would be very beneficial as it seems very very difficult to even understand anything about the problem rather the problem statement and editorial is way too tough to understand , it would be very helpful

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

Hi im a newbie on cf, any tips to reach specialist? i get stuck in adhoc/greedy problems.

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

what do i do now??

Attention!

Your solution 211471860 for the problem 1845B significantly coincides with solutions Isaac_Netero/211471860, musthang/211512249, lepsinach/211512269, atulya_codes_/211516053, hatikyu/211516437. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

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

what do i do now??? please help

Attention!

Your solution 211471860 for the problem 1845B significantly coincides with solutions Isaac_Netero/211471860, musthang/211512249, lepsinach/211512269, atulya_codes_/211516053, hatikyu/211516437. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

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

This is the first time I have received such a warning, and it is evidently a false positive. I have never used any online IDE or commonly published source for competition purposes. I believe this is merely a coincidence, as the solution to problem D is fairly straightforward. Although my rating was not affected since I participated outside of the contest, I would like to appeal against this conviction. Thanks!

Attention!

Your solution 211480048 for the problem 1845D significantly coincides with solutions coderbd/211480048, randomIsNotRandom/211495795. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

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

xD