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

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

Neapolis University Pafos

Привет, Codeforces!

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

В Jul/30/2024 17:35 (Moscow time) состоится Educational Codeforces Round 168 (Rated for Div. 2).

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

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

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

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

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

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

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

as a cyan (specialist) participant I hope to reach blue (expert) after this contest

update: I failed T_T
will try again

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

hopefully specialist after this one, good luck everyone

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

good luck to everyone :)

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

Educational Rounds always make sure participants learn something new every time. Good Luck Everyone !!

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

Hoping to cross the 1300 barrier after this contest. Wishing luck to everyone!

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

as a participant, I will participate

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

Good Luck everyone. May this contest give you a minimum of +100!!

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

potato

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

I am close to green, So I hope today I may reach it again, and best of luck to each participant !

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

Wait, no testers ?!

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

Wait, no testers ?!

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

Hopefully i end in blue after this contest : )

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

as specialist i hope to reach expert after this contest

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

I just hope the pending can be faster.Why pending is often slow?

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

I hope the submission queue is not so long like previous div3 contests, When you get to know after 15 mins about wrong answer.

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

Started to do CP recently, I am finding it hard to select the which technique should be used for each problem and finding it is a big task any ideas and tips to improve the learning and improving

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

    I don't have much experience, but I can say that only practice helps. It can be useful to review the problems and solutions of past competitions (but at the level you feel you can understand at the moment). My mistake was that I analyzed the solutions of the more difficult problems, although I could not solve the easier ones on my own. So I recommend solving gradually, it is better to solve an easier problem yourself than to understand or remember the solution of a harder one

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

    Also at your level I recommend to pay more attention to past div 3 and div 4 contests, usually problems there easier than div 2

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

Hope to reach grey.

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

Hope to reach cyan today

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

Guys the waiting queue is really long(my last submission has already waited for 30 mins),will it be all right before the contest?

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

Let me go back to Expert,CodeForces!

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

manifesting to reach blue today fingers crossed

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

My first unrated Div. 2

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

Really hoping to learn more. Always been told I couldnt do cp

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

the worst round ever. 4 update messages in 20 minutes.

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

What I'll miss is that in the first 20-30 minutes there were four updates to problem B's condition, but problem D is a nightmare. The problem writer has 0 creativity. It’s like I’m reading a study problem>. Worst round

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

speedforces :'(

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

ok so my code that used a Node class and new() TLEs but it runs in 50ms with n=200k on my system.

when i get rid of the Node class and use ints it runs slightly faster on my end but AC

whats the big deal with new() taking forever???

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

    Use global variables, they are faster. Preallocate memory, rather than allocating runtime memory for better performance.

    There are disadvantages also, you need to make sure, you are not allocating more than required, or you will get MLE.

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

12k did C? lol.

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

is this rated for GMs , LGMs, IMs??

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

WTF ????????????? HOW NEWBIES AND PUPILS WITH < 150 PROBLEMS SOLVED ARE SOLVING D ????

5000 ACCEPTED ON D IN A DIV2 ROUND IS JUST INSANE.

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

    Because it is very easy and classical, however I won't deny the presence of cheaters.

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

    its standard problem, cheaters are there tho

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

      can you tell me about that standard problem

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

        i mean say we are on node v with value a[v] and the smallest element from every subtree of v is mn, and then a bit of case handling, if (mn<= a[v]) we go on with mn as the minimum value for the subtree that includes v , else we return (a[v]) + (mn — a[v])/2 that is simply getting both the values to their centre point .

        The idea is that dfs is returning the minimum element in the subtree of the node.

        You can see this soln 273567246 and its standard cuz its the simplest of DFS

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

          Why do we take values to their center? And how does taking to centre ensure that these values of subtree nodes will always be >=0 in the future.

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

            so look i need to set the entire tree up in such a way that the minimum value in the subtree of 1 is maximized , excluding the value of node 1. Why? cuz if the minimum value is increased that means i can perform the operation on node 1, more times before the minimum value in subtree reaches 0.

            For the "if" case, say i have a node with val 5, and it has 3 children with values 3,7,9 now i will simply return 3, why? cuz if i perform any operation on node with val 5, the val 3 will decrease thus decreasing the minimum.

            For the "else" case, say i have a node with val 2 and it has 2 children with values say 7 and 9, so the min value of the subtree currently is 2, but we can make it better , as the minimum value of the child is 7, if i perform the operation twice the values will become 4, 5,7 . so i took them to their centre value. And more operations are clearly of no use as the minimum value that is currently 4 will start decreasing.

            So the idea is MAXIMIZING the MINIMUM in every subtree, beginning from leaf nodes to root.

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

              For the second case you can maximize the root to 11. And the tree after the operations becomes 11,0,2 Can you explain this else case again?

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

                alright so in the second case, lets say x has value 2, and it has 2 children y and z with values with 7 and 9, and x is connected to node 1.

                so the tree is like 1->x->(y,z)

                so the DFS begins, for y it will return 7 and for z it will return 9. now for x the minimum value amongst it's subtrees,i.e. y and z, will be 7. But its own value is 2 which is lower than 7.

                For better understanding , lets suppose we dont do any operations and simply return the minimum then we return 2. and now we are at node 1 , and the minimum element in all its children's subtrees is 2, so that means i can just increase the value of node 1 twice before one of the elements in the tree gets 0.

                Now, suppose we did some operations on x, so minmum amongst it's child subtrees was 7 and it's value was 2, how many operations should i do, such that the minimum of the entire subtree is MAXIMIZED and not only the value of node x? i should do (7-2)/2 = 2 operations so value of x would become 4, value of y and z gets 5 and 7, so the minimum of the subtree gets 4 and i return it , this is the maximized minimum of the subtree. And now i can perform 4 operations on node 1 :).

                Let's say what if i did more oerations on x ? say 2 more operations , x's value becomes 6, y and z become 3 and 5, now the minimum of the ENTIRE subtree is 3 , so that means i can only do 3 operations on node 1, which is not the best possibility , Thats why i take values to the center

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

    IT is a pretty straight forward Tree DP Question. And not everybody learns mostly off codeforces, I just do codeforces for the contests, but rarely for Practice Purposes (except if they appear on USACO Guide)

    But yeah, 5k on D is still quite a lot.

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

    Tbh as a newbie i found D easier than other div2 rounds but sadly i was not able to write code

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

Does anyone else keep getting WA on test case 19 for problem D? Solving E and losing rating is tough :((

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

Imagine looking for an overflow for 30+ mins while telling yourself the following code snippet "definitely isn't the cause, its bounded by $$$n \cdot max(a)$$$".

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

The contest was really easy, the first 4 problems felt like Div. 3, and problem D was very classical.

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

couldn't solve D

I'm so retarded,

doing cf for year and still nowhere near blue

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

how to solve F, I tried many dp approaches but it didn't work.

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

    Note that tokens behave like fibonacci sequence, you have $$$f_1$$$ $$$f_2$$$ and can create some $$$f_i$$$ for $$$i \gt =3$$$ using $$$f_{i-1}$$$ and $$$f_{i-2}$$$ or to change $$$f_i$$$ for $$$f_{i-1}$$$ and $$$f_{i-2}$$$. You can also freely change $$$f_1$$$ to $$$f_2$$$ and vice versa. So $$$f_i$$$ means token on position $$$i$$$.

    First convert all tokens to $$$f_1$$$ and $$$f_2$$$, let the number of them be $$$s$$$. Note that, because you can change $$$f_1$$$ to $$$f_2$$$ and vice versa, all that matter is their sum ($$$s$$$). You want to use minimum number of tokens to represent $$$s$$$. One token means some $$$f_i$$$. If you have $$$1000$$$ $$$f_{10}$$$ tokens maximum $$$s$$$ you can get is $$$55000$$$.

    Now you do greedy, for every sum $$$s \lt = 55000$$$, you go through $$$f_{30}$$$ to $$$f_1$$$ and try to fit sum $$$s$$$ in minimum number of tokens (there is proof for fibonacci numbers that greedy is optimal).

    Now for some sum $$$s$$$ you have $$$min[s]$$$ which represent minimum number of tokens to represent it. We want such $$$s$$$ that $$$min[s] = m$$$.

    Lastly we need to calculate in how many ways can we get sum $$$s$$$ using $$$n$$$ tokens on first $$$x$$$ $$$f$$$s. Define $$$dp[i][sm][p]$$$ as in first $$$i$$$ $$$f$$$s you placed $$$p$$$ tokens and their sum is $$$sm$$$, this dp has at most $$$10*55000*1000$$$ states, transitions are in $$$O(1)$$$.

    Now you just sum $$$dp[x][sm][n]$$$ such that $$$min[sm] = m$$$

    273592555

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

Man A screwed me

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

Why do a lot of people (including me) fail the 19 in D test?

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

someone please tell how to solve E

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

    do it in different ways when $$$x \le \sqrt n$$$ and when $$$x \gt \sqrt n$$$. The former can be pre-calculated, while the latter can be solved by binary searching on prefix-sum

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

    You can precalculate an array of indices for each $$$k$$$, where the indices show where the last update of level happened. I did it with merge sort tree in $$$O(n \cdot log^3_2{n} + q \cdot log_2{n})$$$.

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

    i have an idea that we can group the queries by k
    then for each can simulate the game by using segment tree in $$$O((n / k) log(n))$$$
    so we can do this in $$$O(n * log^2(n))$$$
    someone please correct me if i'm wrong.

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

    Notice that the level you can reach by the $$$i$$$-th monster is non-increasing as $$$k$$$ increases.

    Let $$$need_i$$$ represent the minimum $$$k$$$ for which our level will be $$$\leq a_i$$$ when we reach the $$$i$$$-th monster.

    We can binary search on the value of $$$need_i$$$. To check if $$$need_i \leq k$$$, we want to know if the number of monsters we would have fought till $$$i - 1$$$ is $$$\lt k \cdot a_i$$$, or formally $$$\text{cnt}(need_j \leq k$$$ where $$$j \lt i) \lt k \cdot a_i$$$.

    To check this $$$cnt$$$ quickly iterate in increasing order of $$$i$$$ and store the values of $$$need_i$$$ in a fenwick tree, then $$$\text{cnt}(need_j \leq k$$$ where $$$j \lt i)$$$ is just $$$sum(k)$$$.

    Code — 273568637

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

    Check my comment.

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

Bad round, seriously

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

How do I approach problem D?

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

What is the idea for E?

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

why my code failed for D ? link my solution

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

instant system test complete???

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

$$$O(NX + N^2/X\ log(N))$$$ should be enough to E? I chose $$$X = 1000$$$, and I saw in the worst case it would do like $$$9\times 10^8$$$ operations, and the code executed fast enough, 640ms.

First brute force up to 1000 (ordering queries), then the next I solved doing binary searches in prefix sum to each level up to 200, to find the point of each upgrade.

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

    I think in E you can actually optimize the large $$$k$$$ case using harmonic sums so it becomes $$$O(n\sqrt{n}+nlog^2(n))$$$. i.e. for each level only iterate $$$k$$$ up to $$$\frac{n}{l}$$$ (or so).

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

    You can solve E in $$$O(nlog^2n)$$$, for each $$$i$$$ you can define $$$f(i,x)$$$ as 0 if $$$i$$$ runs for value $$$k=x$$$ or 1 if $$$i$$$ doesn't run for value $$$k=x$$$. See that $$$f$$$ is monotonic so you can binary search it. ($$$f(i,0)=0$$$ for all $$$i$$$ for implementation sake)

    Go through all elements and binary search $$$x$$$ such that $$$f(i,x)=0$$$ and $$$f(i,x+1)=1$$$, in order for element $$$i$$$ to run for some $$$x$$$ there should be $$$a[i]*x$$$ elements that don't run on prefix. You can use ordered set, for calculating how many elements stay/run on prefix. Answering queries is straight forward just compare $$$ans[i]$$$ with $$$x$$$. 273562301

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

    I solved in your complexity. I TLEd under X=1000 and ACd with X=2000.

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

    It can be solved in $$$O((n+q)\sqrt n)$$$ without Binary Search if you maintain both prefix sums and lists of indices that need fight for each $$$k \leq \sqrt n$$$: 273605589.

    I had to use $$$2\sqrt n$$$ for the brute force part to get the memory under 512MB :/

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

Everyone is doing binary search for D while I did entry and exit times with lazy minimum segment tree lol

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

man...penalty sucks

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

As a pupil, I'm hoping to reach legendary grand master after this contest. Wish me luck!

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

Worst contest ever taken...

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

Всем привет, очень интересная ситуация была в этом раунде. Как известно условие второй задачи было изменено после старта соревнований. Что произошло у меня: После решения первой задачи открыл вторую. Далее прочитав условие начал её решать, с оригинальным условием(без изменений) на решение задачи уходило на порядок больше времени(у меня). После того как условие изменилось ко мне не пришло уведомление от CF о том что условие изменилось на странице где я работал(оно пришло на другую страницу), как следствие я потратил час на решение задачи которая по итогу не существовала(и не дорешал). Потом чисто случайно обновил страницу и увидел изменение условия и уведомление на другой открытой вкладке CF. После этого быстро решил эту задачу и ещё одну. Никаких претензий к CF. Как предложение может стоит сделать уведомление на все страницы CF пользователя, а не только на одну? Обидно выходит, что я потратил время на решение не существующей задачи из-за того что уведомление не отработало. А так может быть решил бы и больше)))). Я понимаю как сложно организуются раунды CF, но хотелось бы чтобы подобных ситуаций было меньше. Вдруг я не один такой))))

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

B question was very poorly written i thought if i am not able to do b then how can i do C and further question , it took my whole contest time . Only because it wasnt mentioned clearly that in the starting only at most 1 region is given.

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

who else got WA test 19 on D for binary searching ??

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

one of the worst rounds I have ever done, especially B, I couldn't do it while I solved C in 5mins.

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

I don't understand why B .x.x. .x.x. this circumstance's answer is 0; it should be 6 because any '.' could be the answer , I am so mad that the author don't speak clearly

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

Lol I got cooked in a for starting the matching character check from 1 to n and not 0 to n.

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

Why do I always RE on the D question?(Python)

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

Can someone please check my 2 solution for D and tell me where i could optimize i'm feel defeated at it please anyone spare few minutes on my solution if u want i can explain what i did in my code

Submission 1 TLE Submission 2 MLE

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

it was more like div 2.5

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

worts round for me :( all my progress is gone in just one contest. B was so poorly written, and i couldnt figure out the integer overflow on D. why do i even do cp lmao

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

Could a solution with time complexity $$$O(n \cdot \log(n)^4)$$$ pass for E or would it be too slow?

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

I thought in problem E O(Nlog^3(N)) would fit in TL, but it didn't :/ Submission Can finding the next index from current index i for which count of monsters >= current level is equal to k be done in O(log(N))? I tried binary search + fractional cascading in O(log^2(N))

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

    Hi fellow Sarthak.

    It looks like the runtime of your solution is more to the effect of O(n^2/k) rather than O(nlog^3(n)) since you have nested for loops (iterating by 1 and ~ k respectively).

    The approach I took was to find the smallest k for which monster i could fight Monocarp, each in O(log^2n) time (hint: I used a binary search + seg tree). This allowed queries to be answered in O(1). Hope this helps :)

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

    I did it in$n \cdot log^3_2{n}$ by walking on the segment tree.

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

    Yes, you can do it similarly to the range k-th order statistic problem.

    Let $$$b_{x,i} = [a_i \ge x]$$$ for $$$x \in [1, n]$$$, i.e. each $$$b_x$$$ is an array that contains $$$1$$$s on the positions where $$$a_i \ge x$$$ and $$$0$$$s on the rest. Now, let's build a range sum point update segment tree $$$T_x$$$ on each of those arrays $$$b_x$$$. Finding the next index is just a matter of descending $$$T_x$$$, where $$$x$$$ is the current level, but building those trees naïvely is too slow. However, if you make those trees persistent, then all you need is to build $$$T_n$$$ in $$$\mathcal O(n)$$$ (since level does not exceed $$$n$$$), and then $$$T_x$$$ can be obtained from $$$T_{x+1}$$$ by replacing $$$0$$$s with $$$1$$$s in the positions $$$i$$$ where $$$a_i = x$$$. Since you do $$$\mathcal O(n)$$$ point updates in total, the construction of all $$$T_x$$$ works in $$$\mathcal O(n \log n)$$$.

    I don't know if my code is readable, but just in case: 273556813.

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

I had this idea for D, but couldn't submit it in time. But I keep getting a runtime error on test 19. I'm using Python; can anyone see what's wrong with this submission? My submission to D (RE on test 19)

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

OOf. I solved B for the general case where multiple regions are present. Took me 50 minutes to come up with solution. At that point C already had like 6k solves. Thought solving D will help but nope. Ended up with a Pupil level performance even after solving D. D should not have more than 2k solves imo(even if we take into account how standard it is). Hope the cheaters get pruned.

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

    What was your approach for solving the general case?

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

      Assuming that there are multiple regions present you can do a bfs on the grid to identify and mark all regions. Blocks belonging to region 1 will be marked with the value 1 and so on. While you do this you also have to keep track of the size of every region(can be done using a map). Now the only conditions are: 1. There is one region and we use the editorial logic. 2. There are 4 regions and regions made of a single cell can be blocked to make the total regions equal to 3. 3. Lastly if you have 2 regions and you block a cell such that a region gets divided into 2 regions. 4. The number of regions is 3 and you block a cell in a region which has a size greater than 1(I missed this case actually). If the number of regions is greater than 4 then blocking one block will not be enough. I might be wrong tho.

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

        it's messy for the when there are 3 regions. You can only block the end points of regions. Apart from that I also don't think there can be cases for greater than 4 regions. Your solution seems correct to me.

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

Overflow may be the cause of the Wa test19 on D. When recording the value that needs to be provided to the parent node, it is essential to verify whether this value exceeds the upper limit that the subtree can provide. Otherwise we can construct a case such that all the a_i equals to 0 and the value being transmitted could be vey big.

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

how come 12k solved c. is it that easy.

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

    Cheaters most probably, no matter how easy it was aint no way 12k people solved it suddenly. Also I noted that it happened too quickly. One moment my rank is 2.5k, within minutes it's 6k. But whatever.

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

Problem D if you WA on test19,please check your data scale. In the process of DFS,when the val exceed 1e9 you should return the process.

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

I guess I should re-learn how to read statements after implementing a much harder version of problem B and then deleting almost all of it...

(But please, something as important as "at most 1 connected region" should be bold or in capital letters, or have a bigger font size, whatever, the next time around please...)

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

Is $$$O(nlog^3(n) + qlog(n))$$$ enough to pass E? If it is, could someone explain why my submission got TLE?

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

my best ever contest. First time abcd solve in div. 2. authors were also very nice, I had a very nice and friendly interaction with them while asking questions. Overall, loved the contest but ngl, D was a little bit easier

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

I don't think I've ever blundered this hard in a contest, forgot a return statement in A and forgot to check one cell in B, so by 53 mins I had only C solved + multiple WAs for A and B. (+ I couldn't find the issue in B till the end of the contest :( )

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

Can you guys please try to hack This Solution

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

Some people like problems like B, but I think such subtle statements in the problem statement reduce readability. It becomes more about reading the problem than actually solving it. (Might just be skill issue)

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

Recently cheating has increased quite a lot on CodeForces although problem D was bit standard more like leetcode contest hard question(6 pointer not 7 or 8) but still 5k submissions is really high, the contest went really well for me but still got around 2.7k rank. I have been stuck at specialist rating for some time now due to the high level of cheating. Hope CF will increase action on these cheater

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

for D i try binary search and dfs .it looks right but i wa on 19 for 3 times so sad :(

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

D without binary search and overflow —

Let $$$dp[i] = $$$ maximum possible minimum value in the subtree of $$$i$$$ with optimal operations. We have —

$$$ dp[i] = \begin{Bmatrix} a[i] & \text{ if } i \text{ is a leaf} \newline \min\limits_{j \in \text{ child of } i}(dp[j]) & \text{ if } \min\limits_{j \in \text{ child of } i} (dp[j]) \leq a[i] \newline \left\lfloor\frac{a[i] + \min\limits_{j \in \text{ child of } i} (dp[j])}{2}\right\rfloor & \text{ if } \min\limits_{j \in \text{ child of } i} (dp[j]) \gt a[i] \newline \end{Bmatrix} $$$

Submission — https://mirror.codeforces.com/contest/1997/submission/273602376

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

can anyone help show me what's the wrong test in my solution problem D: 273557414. My idea was collecting points from leaf to root

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

Long time without writing segtree at contest + bad approach (ignored few cases) cost me -3 at final standings.

Approach: let's solve problem offline for each $$$k$$$ in queries.

If $$$k\leq K$$$ (let's choose $$$K$$$ later), than solve with stupid method (just implement statement), requiring $$$O(n)$$$ for each $$$k\leq K$$$, overall $$$O(nK)$$$.

If $$$k \gt K$$$, there is at least $$$ceil(\frac{n}{k})$$$ monsters to be passed before level up. Since there, we can make $$$ceil(\frac{n}{k})$$$ steps for each $$$k \gt K$$$. Where $$$W$$$ -- magical constant, stated as time to be done following: gived fixed $$$r$$$ -- left edge of interval and $$$lvl$$$ -- our current lvl, find minimal $$$i\geq prev$$$, such that $$$count(a_j\geq lvl, r\leq j \leq i)=k$$$. It can be solved in $$$O(\log^2(n))=W$$$ time using segment tree storing sorted vectors of elements on array.

So, let's take $$$K=1000$$$ and final complexity is: $$$O(Kn+n\cdot \log(n)+\frac{qn\cdot \log^2(n)}{K})$$$

WA during contest: 273573012 OK: 273599991

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

It's sad to see that constraints on problem B were corrected(mentioned for the first time) around after half an hour.

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

How do we solve D without binary search?

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

    Yes, we could use greedy. Knowing that if we goes up to a root of some subtrees, those children in this subtree won't be higher (as the operation will make them decreasing by $$$1$$$ each time), so we will aim for maximizing the minimum of all value of this subtree (including the root of this subtree as well).

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

    let dp[u] be the max smallest value of subtree u after doing operations

    for node u: without doing any operations then the min val would be min(A[u],dp[v]) where v are all the children

    you could spend one operation to increase A[u] but that would decrease dp[v] by 1

    so let a = A[u], b = min(dp[v]) if a > b then do nothing (aka dp[u] = b)

    otherwise do k operations until min(a+k,b-k) maximizes (which just so happens to be (b-a)/2 operations) -> dp[u] = min(a+(b-a)/2, b-(b-a)/2)

    for the root/final answer: you could freely do the operation so the answer is A[0] + min(dp[v])

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

can anyone explain me no. B simply, what should i do?

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

    if you delete a cell then the most number of regions that can be created is the number of open cells that neighbours it directly -> it must have 3 empty neighbours

    now imagine this:

    1 v 3

    a 2 b

    v = the node you're deleting

    if a is an empty cell then region 1 and 2 are actually the same region so you'll only get at most 2 regions -> a must be blocked

    same for b and region 2+3

    so the answer is just the number of patterns that are either

    . . .

    x . x

    or

    x . x

    . . .

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

very bad contest for me wasted almost 1 hour 40 minutes just because i thought x is capital and in the end i somehow figured out what was the mistake anyway cheating has been at it's peak today

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

By the way, the custom invocation tab wasn't working today. I tried benchmarking my F to account for hardware differences, but it wasn't responding. Fortunately, it did not matter to me today, but you should probably fix it before the next big event.

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

I don't know who introduced the Cloudflare checking system to codeforces (to check if I'm a human), but I suffered the worst. The problemset was quite standard but it took me aound 7 minutes to enter the contest as 'The system was still checking if I'm a human'. Then after solving A, I could not submit any problem as the same problem kept happening. I tried mobile cf, other browsers, tried to change my net, nothing worked. I guess yeah, my network was quite slow but I could not enter the whole contest after that! I do not blame anyone but it was really a sad contest for me as I was quite hopeful I could solve upto D.

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

I don't know who introduced the Cloudflare checking system to codeforces (to check if I'm a human), but I suffered the worst. The problemset was quite standard but it took me aound 7 minutes to enter the contest as 'The system was still checking if I'm a human'. Then after solving A, I could not submit any problem as the same problem kept happening. I tried mobile cf, other browsers, tried to change my net, nothing worked. I guess yeah, my network was quite slow but I could not enter the whole contest after that! I do not blame anyone but it was really a sad contest for me as I was quite hopeful I could solve upto D.

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

Maybe anyone is interested in non-recursive solution for D, I did it during the contest because was afraid of hack, I thought that recursion depth of 2*10^5 will cause overflow. Also left there recursive function for comparison: https://mirror.codeforces.com/contest/1997/submission/273588364

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

For D , if you are getting WA on tc 19 then putting a boundary condtion that if required subtraction to be done in the subtree > 1e9 , return false may work.

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

For Q-D wa on testcase 19 , putting a condition in dfs function as a base case that if the required subtraction need to be done from the subtree > 1e9 , return false may work !!

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

1

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

Many people solved F with a Fibonacci idea. What was the actual idea?

Can someone link some blogs to read about it and also some problems of a similar idea.

TY in advance :D

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

Greedy for D works too, basically we add to each node until that node is less than or equal to the minimum in its subtree (excluding itself). I did this during the contest

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

Was quite happy to get my rating increased to 1296 after the rating rollback, my highest of all time and was hoping to become 1300+ today. For the first time did problem A in 10 mins. Then I saw problem B's submissions going exponentially like 6000 in the first 15 mins (were 4000 already after I solved A). Got really panicked because I knew I had to bring a rank under 6k for rating increase and at my stage I mostly bring it only from A and B. Still couldn't really figure out B after a long time and till the (the first 50 mins of the contest) it already had 12k ACs. A moment of self doubt came in post that and as for an additional problem, my codeforces would come to verifying you are a human screen and stayed like that for the rest of the contest. Opened it on other browsers and even on my mobile but still the same screen :(. I don't know if this problem happened just for me or everyone else. But the end I was just able to solve A and got a rank of 14500. I think I'd fall back to newbie after this. That proud green color over my name is probably gone now...

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

It's really a good round. Thank you!

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

my solution

Can somebody hack my solution?

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

Can anyone explain why the rank is decreasing during the hacking phase? Thanks!

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

111

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

Someone tell me why my solution to problem D is giving TLE? 273573102

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

    When you call the function traversal, the function will make a copy of m. So if it is called n times, the m will be copyed n times, which will cause TLE. You can pass the reference of m to the function so it won't be copyed when you call the function.

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

(B,C,D) <<<< A <<<<< (E,F)

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

F is a beauty!! loved that the Fibonacci is hidden in plain sight idea!! it had everything, memory optimization, knapsack, and lovely math.

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

"This round will be rated for the participants with rating lower than 2100." Is this contest was rated for newbie or not ??

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

D was a very great problem, but some of my friend get WA on the 19th test

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

first time to solve problem D in contest, and hope to solve problem E in contest one day :)

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

as a tester, i wish you good luck, problems are good

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

Hi, can somebody tell me about the complexity of 273675185

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

I am wondering why someone with red name is official participants. (20240731 08:05 GMT)

However, it said "This round will be rated for the participants with rating lower than 2100" in the announcement.

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

What is wrong with the following submission, it is giving a? as output for s = "a", locally it is working fine.

https://mirror.codeforces.com/contest/1997/submission/273676836

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

    Your first for loop starts from s.size()-2, but input size is 1. Maybe this causes undefined behaviour.

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

    In this part of your code:

            for (int i = s.size() - 2; i >= 0; i--)
            {
                if (s[i] == s[i + 1])
                {
                    n = i + 1;
                    break;
                }
            }
            if (n == -1)
            {
                char ch;
                if (s[s.size() - 1] == 'z')
                    ch = 'a';
                else
                    ch = s[s.size() - 1] + 1;
                cout << s;
                cout << ch << endl;
                continue;
            }
    

    The function s.size() returns the type of unsigned int, so it can't be negative.

    However, you have written int i = s.size() - 2.

    So $$$s.size() == 1$$$ and then $$$s.size()-2 \lt 0$$$.

    Therefore, $$$i$$$ becomes a extremely big number, then will be somewhere successfully match the scentence if(s[i]==s[i+1]), and $$$n$$$ will also become really big, that is, $$$n$$$ will not be $$$-1$$$.

    Thus, it cannot get into the block if(n==-1).

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

Tricky but interesting problem F, enjoy it.

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

Tricky but interesting problem F, enjoy it.

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

Heyy anyone solve D using BS?

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

I want to know that why system testing take much more time than div 1? Can you explain me?

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

    First, open hacking phase adds an extra 12+ hours delay.

    Second, actually easier rounds (educational/div3/div4) are more appealing to lower-ranked people, which actually holds the majority of the users, resulting in more participations, and more codes to rejudge.

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

    This time especially was slower due to crazy amount of TL hacks on E, which was solved quite a lot for its position, and most of solutions on it used a few seconds on each test. Each solution alone took 5-15 minutes to be fully judged.

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

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

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

Wow! Now everyone is rated for EDU!

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

Is this round rated for DIV1 participants?

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

MikeMirzayanov Why was this contest rated for me even though I've long been a master??? I want my rating back.

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

it was better when you make the error

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

I found my contest submission had got a TLE, but when I resubmitted it after the system test, I passed. What's wrong with it?

contest submission, resubmission

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

Can anyone tell why contest official ranking hasn't removed red coders from standings, why they have given ranks in contest

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

Failed to pass F during the contest but passed after finished 8min...

But I reach CM!!!

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

I have one doubt regarding Problem E. In this problem when i used segmented tree my solution exceeded the time limit in test case 12 but when i did the same with fenwick tree it passed . Can anyone tell me the reason behind it? although the updation and query time complexity for both the data structure is same ,that is O(logN). 273965828 Fenwick Tree , 273964980 Segmented tree.