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

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

Neapolis University Pafos

Привет, Codeforces!

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

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

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

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

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

Спасибо тестеру раунда shnirelman за ценные советы и предложения!

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

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

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

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

After the contest I will be live discussion problems I manage to solve. stream link

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

I can't wait to be a expert!

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

No testers?

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

BledDest round. les go

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

Hope able to solve ABC

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

I'm just wonder why there are few Educational Rounds on Saturday...(They are my favourite) As a boarding school students, I only have space time to participate contests on each Saturday, so I can only vp it. :(

Wish there will be more Educational Rounds on Saturday :)

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

This comment is in queue……………

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

Hoping to become cyan

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
Hope for the best, Good luck to everyone!

hoping for no in queue difficulty :)

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

I wish, i would regain CM today.

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

C is way too easy than B.

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

Bad C in my opinion

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

C was kinda easier than A, and definitely easier than B

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

Lmao, solved B,C,D in 30 minutes, but took 30 minutes and 5 penalties on A. Could have had 2100 perf instead of 1850.

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

what kind of data structure might help to solve problem like D, is this well known problem? like evaluate sum of value on every subset?

noticed value of a[i] is small must has something to do this, any hint?

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

Nice D but not C(I don't know how my code for C is true).

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

    if 2 numbers are closer to each other, their product will be bigger, e.g.: n^2 > (n — 1) * (n + 1) > (n — 2) * (n + 2) > ...

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

    If you have 2 numbers $$$x$$$ and $$$c-x$$$ whose sum is a constant $$$c$$$, then their product is $$$x \cdot c - x^2$$$. Differentiating with respect to $$$x$$$ you get $$$c - 2x$$$, and differentiating again you get $$$-2$$$, which is always negative. Thus, setting the first differential at $$$0$$$ gives you $$$x = c/2$$$, which means that the original numbers being closer to $$$c/2$$$ will have the higher product. This is "kind of" common knowledge, but now you have a proof. Algebraic proofs are also common. This one's for the calculus lovers.

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

    $$$xy = \frac{(x+y)^2 - (x-y)^2}{4}$$$ , and as $$$x+y$$$ is constant we should minimize $$$|x-y|$$$

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

I'm genuinely shocked so many people solved C (of course I might just be dumb, as everyone is saying it's easy). Any hints please?

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

C is not at usual level at which C should be it is kind of easier than A

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

Why the orange+ contestants are not out of contest (no asterisk before CF handle at least)?

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

    Asterisk = unofficial participants != unrated participants. Basically there are no unofficial participants in div1/2 contests. In div3 or below, some class of people must participate unofficially to give less motivations to cheat by making official standings consist of "cleaner" people.

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

      Got it, thanks! I think I still don't quite understand the difference between unofficial and unrated. Do you have a clear understanding of that?

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

        Refer to the last div3 contest's announcement for the exact condition to be considered official participants, but in sum:

        • Difference between official / unofficial exists to make the official standings look nicer and discourage unsporting behavior, and only applies to div3 contests or below.
        • Rated / unrated is solely judged by participants' ratings -- people below a certain rating are always rated, regardless of their official / unofficial status.
      • »
        »
        »
        »
        2 года назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        Unrated : When the contest will not affect your ratings due to your current rating range being out of the bounds from the contest. You will be shown in final standings. It depends on your current rating( & no of contests you have participated in for new users).

        Unofficial : You will not come in final standings unless you mark the check box with [] show unofficial. This also includes people who have submitted post contest or during virtual contests. It has nothing to do with your current rating.

        Please correct me if someone has a better explanation.

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

    I also think this is weird. In normal div2 contests they don't appear on the scoreboard unless you tick the "Show unofficial" option. For some reason in educational contests they appear even though the contest is unrated for them, and the option to filter for div2 appears only after the hacking phase (or sometime after the contest, anyway)

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

      In early days educational rounds weren't rated for anyone, so it's not a surprise that everyone was official participant. It's just that at some point it started to be rated for Div. 2 people, among all 'official' participants.

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

Maybe I should only participate in educational contests

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

i don't know why it took me more than 40 minutes to implement a simple knapsack!!!

knew the solution within a minute, i did so many implementation mistakes and so much shitty things, even tried to separate odd and even in dp and tried prefix sums in dp.

was simple knapsack!

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

can anyone tell me why my solution for D doesn't work? (it failed tc 13)

my solution

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

Good contest <3

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

very classic problems. dislike

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

awful wording in E. for 20 mins, I was thinking that each instance of the lightning propogates both left and right. should have just said "choose a subarray such that all elements are +ve and decrement it"

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

Python users on C have a big advantage

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

    how?

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

    Actually, it's not really about large numbers, just the property that the product would be maximized when the numbers are closest to each other.

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

      I also had the same intuition(256377521) but I am not able to prove it, is there any proof of this property that you can provide?

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

        Let us call the constant sum of $$$x$$$, and $$$y$$$, as $$$c$$$. Then,
        $$$x = c - y$$$
        The product, $$$p$$$, can be written as
        $$$p = (c - y) \cdot y$$$
        Differentiating with respect to $$$y$$$, we get
        $$$p' = c - 2 \cdot y$$$
        WLOG, we can assume that
        $$$x \geq y$$$
        i.e., $$$2 \cdot y \leq c$$$
        $$$\implies p' = c - 2 \cdot y \geq 0 \ \ \ \forall y \leq x$$$
        Here, we see, that the first order differential (or the rate of change) of $$$p$$$ is positive over all valid $$$y$$$, i.e., $$$p$$$ increases with $$$y$$$, so we just have to maximize $$$y$$$ (while ensuring that it is less than $$$x$$$)

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

        A simpler proof without calculus:
        Let $$$c$$$, be the constant sum, and $$$p$$$, be the product.
        WLOG, let
        $$$x \geq y$$$
        For some non-negative $$$d$$$,
        $$$x = c/2 + d$$$
        $$$y = c/2 - d$$$
        $$$p = (c/2 + d) \cdot (c/2 - d)$$$
        $$$p = c^2/4 - d^2$$$
        Thus, on minimizing $$$d$$$, $$$p$$$ is maximized, as $$$c$$$ is a constant, which is effectively what you're doing

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

I don't see any point in adding the additional constraint on the number of balls in D.

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

Any hints for E?

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

Got 4 WAs and realized after contest that I was using the wrong modulo value in D :(

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

Why there is not a bigger example for problem F? I took the wrong modulus (1000000007 -> 998244353), got WA verdict and did not realize it until the end, sad.

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

Heavy cheating in today's contest as solutions were released when the contest was running

Nullify this contest otherwise it will be unfair for everyone Here are the links to the cheater's videos' A: https://youtu.be/yXRyAn_SYXk?si=LbSIstKeOXdzgcb1 B: https://youtu.be/jDsYHXQJoWc?si=S4zptf35hazQqu6o C: https://youtu.be/3TrPpil9Xw0?si=BL35v3FAe8phfAID D: https://youtu.be/eJy82kVvRKg?si=ctsUvPCAI8vWN80T

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

My Problem B submission 256318074

Can someone please help in finding out that what is wrong in my logic for problem B, Thanks!

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

    When you want to "merge" 2 nearest numbers, neither of which is equal to a[0], you merge them using only v[i] — v[i-1] — 1 deletions. (However, you are correct in your count of moves, necessary to made first and last numbers in array differ from each over).

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

      3 3 5 3 3 5 3 3 3 For this test case the answer should be 2 right ? I cannot exactly get my mistake And can you please guide me that how can I deal with this type wrong pretests as mostly my logic is correct but I am stuck by a small mistake

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

        Yes, the answer should be 2. Your mistake is that between indices v[i] and v[i-1] there are only (v[i] — v[i-1] — 1) other indices, and not (v[i] — v[i-1]) (as you count in your submission). Essentially, you are deleting 1 more element than you really need.

        I can assure you, that the so-called "+-1 errors" are increadibly common for all programmers, and even after a years of programming you can still make this mistake. But i can afford an approach, which can probably reduce a chance of this mistake for you: in such cases, try to think about every index as a half-interval on the numeric line from zero (not inclusive) to i (incluzive), When you subtract one index from another, you get a length of half-interval from first index (not inclusive) to second (inclusive), meaning length as number of indices this half-interval cover.

        So, in that approach to get the number of indices between i and j, you should just remove 1 excess index from half-interval "j — i" (and that's how you get number j — i — 1).

        Not sure that this is exactly what you needed, but in my experience half-interval thinking often simplifies case analysis "where to assign an extreme value"

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

D was simple Memoization.

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

WA on test 5 in D.

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

Very nice contest. Problems were really good. Thanks for the round adedalic BledDest Neon Roms awoo and all testers.

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

Perhaps E can be strengthened to $$$n\le10 ^ 6$$$

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

I CAN'T BELIEVE IT. This contest is going to pull me out of the swamp of 1790... but too strong.

My first 5 solves Div2, first orange Performance, and Candidate Master is on the way!!

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

    Can you pls provide a proof of "If the maximum of a subset is greater than the sum of the rest of the elements, the value is the maximum; otherwise, the value is ceil(sum/2)" for problem D (for the ceil(sum/2) part)

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

      If one color accounts for more than half of the total, all the rest is not enough to pair up with it;

      Otherwise, you can repeat: group one of each of the 2 colors with the most balls and take them away. In this way, you will not get a 1-ball group except the final one.

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

      This might also help:

      Let's assume we have three (you can assume more too) color balls with count: a a+x a+x+y such that a+x+y<a+a+x for the 2nd process => y<a

      This is what will happen with them as with repeat the process a a+x a+x+y a a a+y a-floor(y/2) a-ceil(y/2) a a+1 a a 1 0 0

      Hope this helps in understanding that at max 1 ball will be left only.

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

How well known is the trick to C? I couldn't solve it and was surprised how many other were able to. Is there a website they went to for tricks like that?

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

A >> D

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

Could somebody help with D solution?

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

Thanks you BledDest and all testers. It was a pure edu2 contest. I think all programmers are glad to participate.

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

Just 3 minutes off of E feels so bad

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

can some1 give me hints in D on how to calculate groups for a certain set

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

Good Edu Round!

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

In the third question it is not writtern that the length of the numbers will be same!!

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

Not expecting this type of contest from BledDest, and I was disappointed.

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

How do you solve F? Initially it looked like a trivial application of Burnside Lemma, but the set of all reachable reachable states $$$X$$$ (here states are different in the usual string comparison sense) isn't acted upon by the cyclic group $$$C_n$$$.

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

    You can still apply Burnside Lemma here, but first you need to extend X to contain all shifts of reachable states. This is equivalent to making X contain all the combinations with no more than k+c 1s and having at least one (cyclic) contiguous segment of c 1s. After applying Burnside's Lemma, you'll end up with a similar subproblem for every divisor of n. Now every subproblem can be solved using inclusion-exclusion principle.

    I believe that this approach can be optimized to solve the problem in $$$O(n*\log\log(n))$$$ time

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

What observation should I make on D?

/hint

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

what I'm doing wrong here? problem D 256376695 any help will appreciate

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

I solved E but I don't know how to solve D >_<

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

This was a really good round (even if I didn't compete), the problemset was superb. I loved D and E. C was a little too easy to be in its position, but still entertaining nonetheless.

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

Is the system testing done?

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

https://mirror.codeforces.com/contest/1954/submission/256346898 this is my submission for B can anyone tell me a test case where it fails ,i tried but couldn't find one?

  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится
    Tests Sample
    Your Code Answers
    The Right Answers
    The Deleted Numbers Order
»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Is it unrated???

UPD:Now It's rated.=)

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

HELP HELP HELP

How can my iterative code giving Stack overflow it does not make sense

256427774

error

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

    Because you are declaring arrays ways and dp of size N*S which can get as high as $$$5000^2$$$.

    And since you are declaring them inside main function, it uses the automatic storage class, which is allocated in the stack frames.

    Stack frame's memory is quite limited and $$$5000^2$$$ integers is a lot.

    I changed the arrays to use static storage class with constant size 5000*5000 here 256430212 and your code passes :)

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

      Thanks for pointing out the issue,

      I am coding in C++ for over 3+ years i did not know that this kind of limit exist.

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

        Note that Codeforces' compiler options make C++'s stack size unusually large. On Windows, the default stack size is 1MB but on Codeforces environment it's set to 256MB (see Codeforces Command Lines). On normal programming, you should never write that kind of code.

        (Small rant: large stack size gives advantages to C++ (and a few other compiled languages that has similar settings), which is kind of unfair to other languages. On C++, you can recklessly write deeply recursive functions thanks to the large stack size -- on the other hand, it's not possible to write deep recursion on Python.)

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

    You can not create such a big C array in function. The stack of a function is only several Megabytes and is only suitable for around $$$10^5$$$ integers. You can try to use a global array which can be much bigger or use std::vector.

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

When are we getting the final results? Have the submissions been checked yet

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

When are we getting the final results? Have the submissions been rejudged yet?

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

Is this unrated?

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

Is this unrated?

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

Is this unrated?

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

please provide an update on when the rating will be updated?

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

when rating will give?

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

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

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

When are we getting rating updates? it’s been over a day already

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

Rating are not updated yet ?? It is rated for div 2 still there are no updates yet.

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

Can someone explain for me why l = ⌈a[i] / ⌈a[i] / r⌉⌉ in problem E?

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

Can someone explain for me why l = ⌈a[i] / ⌈a[i] / r⌉⌉ in problem E?