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

Привет, Codeforces!

В 15.02.2021 17:35 (Московское время) состоится Educational Codeforces Round 104 (рейтинговый для Див. 2).

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

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

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

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

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

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

Codeforces and Harbour.Space

Отличные новости, Codeforces!

Как мы и обещали в прошлый раз, мы вернулись с новой возможностью получить стипендию!

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

В сотрудничестве с Coherra мы предлагаем полную стипендию для обучения в магистратуре "Front End Development" в Harbour.Space, во время которого вы будете проходить стажировку на позиции front end-разработчика в Coherra!

О стипендии:

Работа в самых интересных технологических городах Европы

Размер стипендии до 22900 евро для обучения в Harbour.Space University

Компенсация за стажировку в Coherra

Возможность работать в Coherra полный рабочий день после окончания учебы

Ранее мы сотрудничали с другими компаниями, такими как OneRagtime, Hansgrohe и Remy Robotics, чтобы расширить возможности молодых талантов по всему миру и помочь им построить карьеру в сфере технологий. Мы уже заполнили несколько вакансий с нашими партнерами, в том числе:

  • Место full stack разработчика в OneRagtime занял Alejandro Martinez из Мексики
  • Место innovation designer в Hansgrohe занял Giorgi Zhuzhiashvili из Грузии

Мы всегда рады видеть членов сообщества Codeforces, которые присоединяются к семье Harbour.Space. Подайте заявку сейчас, чтобы получить шанс учиться у лучших в этой области и начать свою карьеру!

Следите за новостями в LinkedIn, чтобы не упустить новые возможности. А так же загляните в наш Instagram, где мы делимся событиями студенческой жизни и историями успеха наших учеников.

Удачи в вашем раунде и до встречи в следующий раз!

Harbour.Space University

Поздравляем победителей:

Место Участник Задач решено Штраф
1 Muffinhead 7 211
2 noimi 7 271
3 LayCurse 7 279
4 satashun 7 333
5 nhho 7 366

Было сделано 90 успешных и 1286 неудачных взломов.

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Задача Участник Штраф
A BOOBA 0:01
B noimi 0:04
C MurasakiShion 0:07
D peti1234 0:06
E Bhaiya_ko_nahi_batana 0:12
F uwi 0:51
G renascencepjw0510 0:27

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

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

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

I wish this contest took place today. For single guys like me this could have been the perfect valentine :'(

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

    But you are not thinking about singles who would have received negative delta.

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

      But he did not say that positive delta is a necessary condition for a contest to be the perfect valentine.

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

        For most of us it is, I would not call a large negative delta contest to be perfect for me and you would agree there would be participant falling into this category.

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

What is the reason behind Educational round not having any testers?

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

I hope that the conditions will also be short and clear as in the last round :)

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

I will do a stream after the contest, on https://twitch.tv/AnandOza

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

    Can you please shift to YouTube, you'll certainly get a larger watch base over there. Who watches coding videos on twitch anyways?

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

      Twitch is objectively better than YouTube for streaming

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

        Maybe, but I don't understand very well why people are so obsessed with streaming. I mean, It would be much better to make and edit video editorials and then submit them. Viewers could ask questions in the comment section or the author could make a live broadcast for Q&A.

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

          It is more interesting for the content creator to stream and chat live with the subscribers than to record alone and then answer questions in the comments. Moreover, the content quality actually goes up if you are streaming, because all the frequent questions are answered directly in the video and not somewhere in the comments where you have to find them first.

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

      I upload my broadcasts to YouTube later, and post screencasts on YouTube as well. Feel free to subscribe at https://www.youtube.com/c/AnandOza.

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

Can we expect short statements? It would be very pleasant to see short statements on the problems :)

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

    Can we expect strong pretests? It wouldn't be very pleasant to see FSTforces. :) (FSTforces makes +136 for me) forgive my poor English:)

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

Just 1 day earlier and this contest might be my savior in the day that wasn't born for a single like me

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

Yesterday was 3 years since my first contest, that was a Valentine contest. As luck would have it, problem A was the most difficult in the history of the Div2 rounds, its difficulty was 1400 !!!

Meme of that round:

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

All I wanted from Mike:

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

Is it not true that the round is Rated?

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

    Is it (not true) that the round is Rated? => Is it false that the round is Rated? => is this contest unrated? This is what we expect from div2. A problem.

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

H

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

Hello guys finally i am back after a pause of 20 days because of my faulty laptop but hey... i have practicing on paper a lot ....so i hope today i become specialist . As always good luck to all. Keep Coding!!

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

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

Can somebody recommend me some basic problemset on DP and Graphs. I am able to solve standard problems but I struggle a lot on codeforces. Please recommend some good resources for the same too.

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

Valentine’s Day is the programmer’s holiday.

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

Really Excited for this contest, in last 2 contests I dropped down my from my Specialist spot. Hope I will regain it in this Contest. Good luck to everyone <3

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

those cyans who will be blue today will regret tomorrows div3

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

Is this TypeRacerForces?

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

I didn't like a single one of the problems, and probably no one did. Is there a joke I didn't get? Why did you do this?

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

I think I burned my every brain cell solving C. Atleast I succeeded.

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

How come (sqrt(2 * n + 1) — 1) / 2 isn't the solution in D?

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

    2*n-1 not 2*n+1 :)

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

      I know it's a dumb question, but I'm still not getting how.

      We have:

      a^2 — b = sqrt(a^2 + b^2)

      a^4 — 2a^2b + b^2 = a^2 + b^2

      a^4 = a^2 + 2ba^2

      a^4 = a^2(1 + 2b)

      => a^2 = 1 + 2b

      b <= n => 2 * b <= 2 * n + 1

      I'm sorry again if I made some mistake, but please correct me in the place I am wrong.

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

        c=b+1 so actually b<=n-1.

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

          Oh, I solved the system of equations wrongly, shame on me. Thanks for explanation.

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

        Hear me out!

        $$$(d(m^2+n^2))^2=(d(m^2-n^2))^2+(d*2mn)^2$$$

        then either:

        $$$m^2+n^2=d*(2mn)^2-(m^2-n^2)$$$

        or

        $$$m^2+n^2=d*(m^2-n^2)^2-2mn$$$

        first one gives

        $$$2m^2=d*4m^2n^2$$$

        so

        $$$1=2dn^2$$$

        which is impossible

        the second one gives

        $$$(m+n)^2=d(m-n)^2(m+n)^2$$$

        which gives $$$d=1$$$ and $$$m-n=1 <=> m=n+1$$$ so basically solutions are of form

        $$$(2a^2+2a+1, 2a+1, 2a^2+2a)$$$

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

    it is (sqrt(2*n-1)+1)/2-1

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

I can't be the only one who found D easier than B?

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

    And easier than C as well ...

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

    I just searched it on Wolfram Alpha

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

    Yeah for me D was easier than B and far easier than C. How did you guys solved C?

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

      Parity of sum i+j. If the number of teams is even, game of teams $$$2k$$$ and $$$2k+1$$$ $$$(k=0...\frac{n}{2})$$$ is a tie

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

        My solution is very different and I am yet to prove why it is correct Basically we can find a formula $$$n(3n - 3 - 2s) = \sum{t_i}$$$ where $$$s$$$ is score of each team and $$$t_i$$$ is number of ties played by team $$$i$$$. Here comes my unproved assumption that each team will play same number of ties. Now to minimise total ties maximize score and then I just greedly assigned wins, loses and ties and I don't know why this is correct

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

          By giving explicit constructions, we can show that it is possible to have $$$0$$$ ties if $$$n$$$ is odd, and $$$n/2$$$ ties if $$$n$$$ is even. So, to prove correctness, we only need to show that when $$$n$$$ is even, then $$$n/2$$$ ties is the best number of ties possible.

          Claim: If $$$n$$$ is even, then the minimum number of ties must be at least $$$n/2$$$.

          Proof: If there are exactly $$$T$$$ ties among all $$$\binom{n}{2}$$$ matches, then the total score of all teams must be $$$3\left(\binom{n}{2} - T\right) + 2T = \frac{3n(n-1)}{2} - T$$$. Since each of the $$$n$$$ teams gets the same score, this number must be divisble by $$$n$$$.

          We now use the assumption that $$$n$$$ is even. We can assume that $$$n = 2k$$$ for some positive integer $$$k$$$, and hence, $$$\frac{3n(n-1)}{2} - T = \frac{6k(2k-1)}{2} - T = 6k^2 - 3k - T$$$. This must be divisible by $$$n = 2k$$$. It is easy to see that this is true when $$$T = k = n/2$$$, and there is no smaller possible value for $$$T$$$. $$$\square$$$

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

            I believe that this solution gives another nice proof of why the number of ties is optimal (since it argues in terms of in-degrees and out-degrees of a vertex which need to be equal).

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

            From this, we can also show that for any optimal configuration with even $$$n$$$, each team must have exactly one tie.

            Indeed, from the proof above, we know that the total score of all $$$n$$$ teams is $$$6k^2 - 3k - k = 6k^2 - 4k$$$, so the total score obtained by each team is $$$\frac{6k^2 - 4k}{2k} = 3k - 2$$$, which is not a multiple of $$$3$$$. On the other hand, if a team has no ties, then their total score is a multiple of $$$3$$$. So, it is impossible to have a team with no ties. Each team must have at least $$$1$$$ tie.

            Together with the fact that there are $$$n/2$$$ ties in total, it is easy to see that each team must have exactly $$$1$$$ tie.

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

      Greedy)))

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

    I misread the statement of problem B :( And stuck on it for an hour...

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

can anyone explain how to approach question d..like i am failing in the tc.

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

    From the two formulas it follows that $$$c=b+1.$$$ Moreover, difference between $$$c$$$ and $$$c-1$$$ must be a square

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится +2 Проголосовать: не нравится
    • `It involves a bit of mathematics. So you have 2 equations

    1) a^2 + b^2 = c^2

    2) c = a^2 - b

    • From equation 2, find the value of a^2, which is c + b and then substitute it in equation 1. From there, you will a relation of the form c * (c-1) = b * (b+1). On careful observation, you will see that this can be true only when b = c-1. So, the problem reduces to counting the number of pythogorean triplets having the length of the hypotenuse and the longest leg differing by 1.

    • As it turns out, such a triplet has the form (2n + 1, 2n^2 + 2n, 2n^2 + 2n +1). Here is the hypotenuse is of the form 2n^2 + 2n + 1 and hence you can easily loop until you reach the limit.

    • Link to my submission: https://codeforces.com/contest/1487/submission/107441210

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

    Pythagorus theorem -> a*a+b*b=c*c , a<=b<=c

    and eqn in question -> c=a*a-b

    solving both equation we will get c = b+1

    so let b = m then c = m+1 and a = sqrt(2*m+1)

    since c<=n

    so m+1<=n => m<=n-1 => 2*m<=2*n-2 => 2*m+1<=2*n-1

    sqrt(2*m+1) <= sqrt(2*n-1)

    so our ans is number of odds(since 2*m+1 is of odd form) less than or equal to sqrt(2*n-1)

    but we have to subract one from our ans since sqrt(2*m+1) cannot be 1(if it is 1 then m = 0, which is not possible).

    Hope it helps.

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

    c=a2-b

    a2=c+b

    3*3=9=4+5

    5*5=25=11+12

    7*7=49=24+25

    9*9=81=41+40

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

Anyone have a clue what test 18 of E is?

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

I think that there is a bug with the penalty for wrong submissions for this round. I made one wrong submission for problem B(and got no time penalty) and three wrong submissions for problem C (and got only two time penalty).

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

Is E just doing DP courses by courses and for storing DP values of previous course in segment tree to get DP values in current course i.e. for DP[i] in current course we will get $$$m$$$ segments in previous course to consider value?

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

    You don't need a segment tree, just a set that contains the previous dp values. For each dish, remove the dp value of dishes that don't go well with it and insert them back afterwards.

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

    We can see that m_i is less than 2000000, so we just sort the DP value of the last course. Then we just select the minimum DP value (and skip the DP value if they can't get well with each other) for each current course and generate a new DP value.

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

    We can solve E with brute force. For each vertice i from 2 to 0 brute the minimum valid vertice (i + 1). And it work O((n + m) * log2(m))

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

Wrong answer on test 40 on E :( This is annoying

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

The risk I took while submitting C was calculated but I forgot that I'm bad at math (-_-)

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

[pE] What's the point of having 4 things.

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

    Exactly :(

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

    Well, the main reason is that, on 3 dishes, you can iterate on the second one and take the cheapest first and third option that goes well with it.

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

Maybe the gap between E and the last two problems are a little bit too large(which according to the statistics are solved by 973,14 and 42 participants respectively)

anyway,good problems and strong pretests!

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

ParityForces

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

This contest was not at all educational.

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

The formula of D is $$$ b(b+1)=c(c-1) $$$ i.e. $$$ b=c-1. $$$ Difference of squares $$$ n^2-(n-1)^2 = 2n-1. $$$ For all $$$i=3...10^5$$$ write down all $$$n$$$ such that $$$ n^2-(n-1)^2 = i^2 $$$ (or $$$i^2 = 2n-1$$$ or $$$n=\frac{i^2+1}{2} $$$) and use binary search to count the answer

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

Any ideas why this gives wrong answer in test 24 for E:107463591

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

Can someone explain the approach for problem E? I think we have to start finding the minimum value from each of the n3 values to n4. Now we will move to n2 and then find the minimum from n2 to n3 for each n2 and so on.... Am I correct? If the logic is same then how all of you optimized?

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

    I wasn't able to code completely but i think following would have worked :

    Consider a,b,c,d as arrays consisting of cost of first course, a second course, a drink, and a dessert.

    Now in array b , for each index we can add minimum cost in array a.

    Similarly for each index in c we can add minimum cost in array d .

    In both above we need to consider only those pairs which are not connected . It can be done with multiset .

    Now for each index in b find minimum cost in c and take the minimum.

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

      Yeah I am saying the same thing. But isn't finding minimum will be O(n^2)? How are you optimizing it?

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

        Suppose for each value in $$$b$$$ we need to find minimum cost in array $$$a$$$. You can create multiset consisting of pair $$${a[i],i}$$$ . Now you can create adjacency list for array $$$b$$$ such that for each $$$b[i]$$$ it contains all $$$i$$$ in $$$a$$$ which it cannot be paired with.

        While traversing $$$b$$$ , at particular $$$i$$$, remove all those pairs from multiset and then take the minimum value . finally add again all those values back.

        Similarly for all other parts.

        Complexity would be $$$O(max(n,m)log(max(n,m)))$$$ where $$$m$$$ is all the pairs which are incompatible .

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

    You can use multiset to get the minimum value. While looking at the i'th element delete the values of the food which doesn't go with i'th element. Now get the minimum value in multiset. At last of i'th step add those deleted values back into multiset.

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

      Ohh great!! Deleting the elements and then adding the same elements in the multiset, I haven't thought of. Thanks !!

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

the contest is done. Can I legally upload my solutions to github?

will there be information for the solutions of the problems(unhappy to say I need only for B and C) ?

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

Thanks for the contest, even though I couldn't perform well, I got to learn a bunch of things!

Kudos to the authors

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

I don't know why my D solution was giving TLE using C++14 and then got AC after I submitted with C++17. Can anyone please help me out?

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

    wait, your solution's time complexity is O(t * sqrt(n)), and in the worst case it has to do ~3*10^8 , how can it pass?

    I've submitted your solution and here is the result:

    • GNU C++11(or C++14): >2000ms

    • GNU C++17: 1965ms (surprised face)

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

    Probably some slight difference in the compilation process based on the chosen standard that leads to a small difference in runtimes, or just normal run to run variability, since you are very close to the limit.

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

Getting input on E was harder then solving real problem

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

Why always easier G than F in edu rounds?

upd: sorry, it seems just last two round has easier G, but why?

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

Solved A in 2 minutes and given rest 118 min to the B, finding patterns in the smaller input. But, was not able to crack it. WTH!! happened to my brain. Ahh... this feeling can't be expressed in words.

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

Approach for D :
c = a*a-b & c = a*a+b*b
c*c = (a*a-b) * (a*a-b)
a*a + b*b = a^4 + b*b-2*a*a*b
On simplifying,
a*a=2*b+1
Now you can do a binary search for this.

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

Which formular we need to google or recite to solve D?

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

      I also did read this page...and then?

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

        $$$c+b=c^2-b^2\implies c-b=1\implies m^2+n^2-2mn=(m-n)^2=1\implies m=n+1$$$

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

          I did not liked the problem, but this explanational formular looks good, thanks!

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

            There should be some easier way to think but I've seen this formula before so I immediately think about this.

            • »
              »
              »
              »
              »
              »
              »
              3 года назад, # ^ |
              Rev. 3   Проголосовать: нравится +21 Проголосовать: не нравится
              1. $$$c^2 = a^2+b^2$$$

              2. $$$c=a^2-b$$$

              3. $$$(a^2 -b)^2 = a^2+b^2$$$

              4. $$$a^4+b^2-2a^2b = a^2+b^2$$$

              5. $$$a^2(a^2-2b)=a^2$$$

              6. $$$b = \frac{a^2-1}{2} \implies a \ is \ odd \implies a=2k+1\ for\ some\ k$$$

              7. $$$b = \frac{(2k+1)^2-1}{2} = 2k^2+2k = 2k(k+1)$$$

              8. $$$c = a^2 - b=(2k+1)^2-(2k^2+2k)=2k^2+2k+1 = 2k(k+1)+1$$$

              9. We already have $$$ a\le b\le c$$$ (easy enough to check that this is true for every k)

              10. Therefore, imposing $$$c \le n$$$ would suffice.

              11. $$$2k(k+1)+1 \le n \implies k(k+1) \le \lfloor\frac{n-1}{2}\rfloor$$$

              12. Therefore, $$$k \lt \sqrt{\lfloor\frac{n-1}{2}\rfloor}$$$

              13. You have your answer $$$\lfloor\sqrt{\lfloor\frac{n-1}{2}\rfloor}\rfloor$$$ (or 1 less than this quantity, has to be manually checked) in $$$O(1)$$$ :)

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

    The pythagorean formula, $$$a^2 + b^2 = c^2$$$, and the given formula in the problem, $$$c = a^2 - b$$$, are enough.

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

    Pythagorean Theorem: $$$a^2 + b^2 = c^2$$$. Then you couple that with $$$c = a^2 - b$$$ to solve for bounds on the variables. I thought it was strange they didn't include that in the problem statement, but I guess problemsetters deemed the theorem fundamental enough, since most people learn it in primary or secondary school.

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

      Well, I remembered pythagoras, the problem was more "to solve for bounds on the variables.".

      I assume that was in secondary school, too.

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

    c^2 = a^2 + b^2
    c^2 = a^4 + b^2 — 2*a^2*b
    a^4 — 2*a^2*b = a^2
    a^2 (a^2 — 2*b — 1) = 0
    b = (a^2 — 1)/2

    So the maximum value of n was 1e9 so the max value of a would-be sqrt(2*n + 1) would be the order of 1e5(let us call this N). We will maintain 2 arrays, pref[N] and num[N].

    Loop a from 1 to N and calculate b and c. If b and c are integers and c <= 1e9, put num[a] = c and pref[a]=pref[a-1] + 1. Otherwise num[a] = num[a-1] and pref[a]=pref[a-1].

    For each test case binary search on num and get the index ind such that num[ind] <= n and answer would be pref[ind]. I am leaving the edge cases to you.

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

    The answer is just (int(sqrt(2*n-1))-1)/2

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

    You don't need a formula besides the ones provided. Just need to know how to substitute one equation into another and do some algebra.

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

Who else got memory limit exceeded in E?

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

Due to a typo, I somehow found that min(v.begin(), v.end()) compiles, but will probably give wrong answer. It took me so long to find the typo. Can someone explain why it compiles and the result of it?

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

    min function takes two arguments of same type and returns the minimum value of them. It uses "less than" operator to find the minimum. Here if v is a vector then "less than" operator is defined for vector iterator. So it works.

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

      Omg this should be quite obvious! I don't know why I didn't think about this. Thank you for the explanation!

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

E was so painful to solve!

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

Something is special with the number 1337. I see it everywhere :)

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

    It's leet written in leet the langage where you change letters to other character in order search for words doesn't work

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

Me whole time, during the contest.

Kudos to 6th consecutive negative delta

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

I solved F using a simple Dijkstra. I have no proof why the number of states is small enough.

Can you hack it or prove its correctness?

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

    The entire state space your Dijkstra routine is exploring is of size $$$O((\log n)^2)$$$. Consider the number $$$x = 9*\mathrm{curr}$$$, written with no leading zero. Then your two operations on $$$\mathrm{curr}$$$, viewed as operations on $$$x$$$, are:

    1. invert every digit in $$$x$$$, or
    2. subtract 1 from the leading digit of $$$x$$$, then add 1 to $$$x$$$.

    Then it should be easy to see that from a given value of $$$x$$$, there are at most $$$2 \times 10$$$ values of $$$x$$$ that can be reached with the same number of digits, and at most $$$2$$$ values of $$$x$$$ with one digit less. These $$$2$$$ values will (up to inversion of digits) differ by either $$$9$$$ or $$$10$$$. Extending this idea, up to inversion of digits, the ways to remove the first $$$k$$$ leading digits of $$$x$$$ fit within a range of size $$$10k$$$. This leads to there being at most $$$20k+1$$$ of them, which leads to the $$$O((\log n)^2)$$$ bound I claimed.

    EDIT: I made a dumb oversight initially, but the idea of this comment should still more or less work. I expect the constant factor is in practice better than what my revised argument suggests, by about a factor of 5.

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

i was counting the pythagorus tripets where c=b+1 by the loop of pythagoras generator and it is giving TLE error any easier method ??

void pythagoreanTriplets(int limit) 
{ 
  
    // triplet: a^2 + b^2 = c^2 
    int a, b, c = 0; 
  
    // loop from 2 to max_limitit 
    int m = 2; 
  
    // Limiting c would limit 
    // all a, b and c 
    while (c < limit) { 
  
        // now loop on j from 1 to i-1 
        for (int n = 1; n < m; ++n) { 
  
            // Evaluate and print triplets using 
            // the relation between a, b and c 
            a = m * m - n * n; 
            b = 2 * m * n; 
            c = m * m + n * n; 
  
            if (c > limit) 
                break; 
  
            //printf("%d %d %d\n", a, b, c); 
            int d=max(a,b);
            if(c==d+1)
            ans++;
        } 
        m++; 
    } 
} 
  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    We have 2 equations. 1) c^2 = a^2 + b^2 2) c = a^2 — b

    If we substitute the value of c from 2nd eqn. to first eqn. we get,

    a^4 + b^2 — 2*a^2*b = a^2 + b^2 ==> a^4 — a^2 = 2*a^2*b (By rearranging terms) ==> b = (a^2-1)/2 ==> c = (a^2+1)/2 (By substituting the value of b into eqn.2)

    We can see that c>=b>=a. For c to be less than or equal to n, a<=sqrt(2*n-1). Also for b and c to be integers a should be an odd number != 1.

    So the answer is number of odd numbers from 3 to sqrt(2*n-1)

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

    Yes...use the same function to precompute the all the pairs till 10^9 and store a,b,c in different arrays let's say A,B,C..now for each n..check how many elements in C are <= n as because C will be holding the max element of each triplet of a,b,c. This is not the best method to solve this question but yes this approach works for given constraints.

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

Why does DFS by complement fail on E :(

submission

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

Why does DFS by complement fail on E :(

submission

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

PatternForces

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

Deleted

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

how to solve C

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

    The main idea is we can put the teams on a circle. Then if $$$n$$$ is odd team $$$i$$$ won from teams $$$i+1,i+2,...i+\frac{n-1}{2}$$$(with cylic shift). And if $$$n$$$ is even team $$$i$$$ won from teams $$$i+1,i+2,...i+\frac{n-2}{2}$$$ and tie with team $$$i+\frac{n}{2}$$$.

    code

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

    Solution. You can fill adjacency matrix with checkerboard pattern (if $$$n$$$ is odd), mirrored by main diagonal. Then every line and every row has the same sum. In case $$$n$$$ is even -- every team must play one game in a tie. Simplest way to put 'tie values' on adjacency matrix such that any two 'tie values' are on the same row/column -- put them on second diagonal by checking the sum of indexes $$$row + col == n$$$. Bus you also need to mirror values by second diagonal (only in case of $$$n$$$ is even).

    Example or filled matrix (according to described pattern)
    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      thanks for your efforts

      but after giving 2.5hours+ still i am not comfortable that how this is working ..... i know this is a valid pattern but unable to answers whether i can think this on my own in or after contest..

      at the end ..... waiting for editorial.......

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

    You can solve C by induction.

    Odd N Solution
    Even N Solution
    ODD N Example
»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

why this solution is not getting TLE? Link: https://codeforces.com/contest/1487/submission/107421373

Because the number of time for loop running = 22360*10000 = 223600000 ~ 2*10^8

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

Please, Can someone help me understand why below output(sequence) is wrong for Que C : Minimum Ties

when input is n = 4

my output(sequence): 1 -1 0 1 -1 0

I'm getting WA on testcase 2, my submission

Thank You!

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

    According to your output sequence, scores are not coming out to be same for all the teams (1->4,2->3,3->4,4->5). I think you are taking the score of match tied as 0.

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

Why this solution is not getting TLE?

Solution Link:https://codeforces.com/contest/1487/submission/107421373

Because the total number of times for loop is running = 22360*10000 ~ 2*10^8

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

    With O2 and Intel's good branch predictor, CF's judger isn't too slow

    So it isn't TLE

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

    Actually, it still passes without pragma optimize. 2*10^8 is small enough on codeforces when having small constant(you only do a few operations in the loop).

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

I solved

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

    The O(t*sqrt(n)) solution can be optimized to O(sqrt(n) + t*log(n)) if one precalculates all triples and for each test case does binary search

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

How do you solve E?

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

    You can build up the answer in bottom up manner.

    Step 1 : Try to find answer for all drinks , given that it can go well with a few desserts.

    Step 2 : Try to find answer for all courses of Type 2 , given that it can go well with a few drinks.

    Step 3 : Try to find answer for all courses of Type 1 , given that it can go well with a few courses of Type 2.

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

I know math is very important in competitive programming. But isn't this too much?

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

Please, Can someone help me understand why below output(sequence) is wrong for Que C : Minimum Ties

when input is n = 4

my output(sequence): 0 1 -1 0 1 1

I'm getting WA on testcase 2:https://codeforces.com/contest/1487/submission/107460842

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

    YOUR OUTPUT : 0 1 -1 0 1 1
    That is
    1 2 — TIE
    1 3 — 1 WON
    1 4 — 4 WON
    2 3 — TIE
    2 4 — 2 WON
    3 4 — 3 WON
    Total Points:
    1 -> 3 + 1
    2 -> 3 + 1 + 1
    3 -> 3 + 1
    4 -> 3

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

the game may result in a tie, then both teams get 1 point.

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

Joke problems in an edu — round . first 4 problems are joke.

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

In C, I was able to find the solution pretty quickly but for 1.5hrs could not find a way to implement the ordering. Anybody faced the same issue, and then i matched i with i + n/2 (for tie ) and brute forced rest of the pairs and it passed (maybe it will fail later) ... The ordering of win and loss for any pair

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

    I mean how to decide which pair will be loss , win or tie

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

      Here's what I thought while solving problem C:

      Consider each team as a vertex in a complete graph. Then you need to direct edges (outwards for a win, inwards for a loss) such that the in-degree and the out-degree are the same for any vertex $$$v$$$, and we need to maximize the number of directed edges. The maximum in-degree or outdegree can be at most $$$\lfloor\frac{n-1}{2}\rfloor$$$ (since there can be at most $$$n - 1$$$ edges incident on any vertex). A construction for this is pretty simple too: For any team $$$i$$$, let it win against teams $$$i+1, i+2, \ldots, i + \lfloor\frac{n-1}{2}\rfloor$$$, where indices are taken modulo $$$n$$$. The construction guarantees that you assign one pair of teams a win/loss at most once, and since there are incoming edges from $$$i-1, i-2, \ldots, i - \lfloor\frac{n-1}{2}\rfloor$$$ (indices taken mod $$$n$$$), the constraints are satisfied as well.

      To implement it, you can simply create a matrix $$$a$$$ where $$$a_{ij}$$$ is $$$1$$$ if there is an edge from $$$i$$$ to $$$j$$$, $$$0$$$ if it is undirected, and $$$-1$$$ if there is an edge from $$$j$$$ to $$$i$$$, and print in the order specified in the problem statement.

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

        nice way to think

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

        Then you need to direct edges (outwards for a win, inwards for a loss) such that the in-degree and the out-degree are the same for any vertex

        Couldn't you have a case, in theory, where one player has 3 draws, and another one has 1 win and 2 losses, with them having the same number of points?

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

          Let $$$T$$$ be the number of tied matches. Then in a state with everyone having the same score $$$S$$$,

          $$$(SumOfScores) = N * S = 2 * T + 3 * (N * (N — 1) / 2 — T) = 3 * N * (N — 1) / 2 — T$$$

          Middle equality is just summing up scores for each matches (2 for each tied matches, 3 for non-tied ones)

          Odd $N$ case is very obvious so I'll skip.

          If $$$N$$$ is even, after dividing both sides by $$$N/2$$$, we get

          $$$2∗S=3∗(N−1)−T/(N/2) \leftrightarrow T/(N/2)=2∗S−3∗(N−1)$$$

          This implies $T$ is divisible by $$$N/2$$$. Since the right hand side is odd, we can't have $$$T = 0$$$, so the smallest candidate of $$$T$$$ is $$$N/2$$$.

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

            This is exactly how I also solved(1st two lines of your comment). but for distributing the win/tie match I didn't thought of anything just did a brute force my_sub. I didn't prove why this way of distribution work

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

            What a nice proof!

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

            can you please say the odd case explaination?

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

            if N is odd and if we furter solve we get 2*N*S=3*N*(N-1)-2*T if T=0 we get LHS =EVEN and RHS =EVEN so minimum T value is 0 is this correct?

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

        As arman.t mentioned, it's not immediately clear to me why each team needs to have the same number of wins and loses in any optimal configuration. In fact, this isn't true if we modify the number of points awarded for wins/ties/loses. For example, if winners get 2 points instead of 3 points (and everything else is the same), one optimal configuration of 4 teams with 3 total ties is as follows:

        	A	B	C	D	Total	Wins	Ties	Loses
        A	-	1	1	1	3	0	3	0
        B	1	-	2	0	3	1	1	1
        C	1	0	-	2	3	1	1	1
        D	1	2	0	-	3	1	1	1
        

        Edit: On second reading, maybe I misinterpret your comment. Are you saying that a team must have the same number of wins and loses although the number of wins of distinct teams can be different?

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

          Nice catch, I probably should have mentioned why the number of ties is minimized there. Note that if $$$x$$$ is the number of ties, the total number of points is $$$3n(n - 1)/2 - x$$$, and this needs to be divisible by $$$n$$$. If $$$n$$$ is odd, we're done by the construction since there $$$x=0$$$, and otherwise, the first expression is $$$n/2$$$ modulo $$$n$$$, so $$$x$$$ needs to be at least $$$n/2$$$, which the construction achieves. As for your observation, replacing $$$3$$$ with any odd number works, but might not work when we replace it by an even number.

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

    Simple way of ordering for odd value do this way.

    -LWLW

    W-LWL

    LW-LW

    WLW-L

    LWLW-

    For even do this way.

    -DLWLW

    D-WLWL

    WL-DLW

    LWD-WL

    WLWL-D

    LWLWD-

    alternate LWs only no complex logic as matrix is symmetric around the diagonal.

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

Educational round is too harsh.....I solved A and D but still getting a negative delta in pupil.....If it was a point based div2 I could surely have got some positive delta.....Though i am very upset with my low performance of not even being able to solve B and C today...

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

    This round was pure garbage (and I am speaking regardless of my poor performance). First four problems were all of same level. E and onward are of decent quality, but most participants didn't make it 'til that point, because of B/C fails.

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

      How they would do E if they can't do B/C? There is some examples of opposite, but there is few of them

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

        I never stated they would solve them, it's just that the first four problems provided no value whatsoever. When I can't solve a nice D2D, I spend a few hours analyzing it, but I don't regret missing today's B at all.

        E. g. I got stuck on B for an hour or so, then solved C and D in no time (messed up the +/- thing in D, but still solved 80% of the problem), does that mean that B was super hard or that I'm stupid, no? There were just too many simple tricky problems in today's round, that's all.

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

Totally speedforces. You should have excluded one of the problems from A-D, because 4 div. 3 problems on educational contest is very unacceptable There are pupils and even newbies getting negative delta for solving 4 problems, This does not happen even in div. 3 rounds.

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

    That's not true no pupil or newbie is getting negative for solving all 4. (even with absurd amount of penalty).

    agreed with the argument that problems were easier than your typical educational round but it's always like this.. some days the problems are balanced, some days they are tough and some days they happen to be lenient.

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

Can someone explain the logic of problem F? Is it digit dp? If yes then how you used it?

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

Here is my 1 line code of problem-D ..xD

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

code Problem C

Can someone please explain why my code written in C11 got a TLE? T_T

I wonder if it got trapped in an infinite loop or the code is just too slow.

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

    You can test the code yourself with Custom Invocation, right? Your code runs that test 3 in around 1500ms.

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

Thank you so much for the Hardwork of making this Contest.Really enjoyed and learned new things.

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

Is this contest unrated?

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

When is editorial coming??

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

A good contest for me. Finally solving A & B both in educational round. Feeling good

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

In problem C. For n = 4 according to my approach the output is 1 -1 -1 1 0 0 and the compiler output is 1 0 -1 1 0 1. My output was shown wrong because the score of 1 and 2 are not same. But I didn't see anything difference between (1 -1 -1 1 0 0 and 1 0 -1 1 0 1). Can anyone explain it please?

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

Can someone explain on how to solve problem E ?

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

    Sorry for my poor English.I will try my best to explain my idea. First,divide the original into three parts:the first with the second,the second with the third,the third with the fourth.Then let's solve the first part:the first kind food with the second.What we want to know is for every food in the second list,which food can be selected with it and cheapest.To do that,we can form a graph and use a map to store all the price of the first kind.Then just iterate every second food,and delete the food that cannot be selected with it in map.Finally,we can easily get which one is the cheapst or clarify there is no food can be selected with it.After this,add the elements deleted before and do again for the next second food.
    To calculate the real answer,we can add the selected price with the price for the second food.Then do this for the second food and the third.Finally,the price of the fourth food would be the answer.
    Here is my solution link:107496598

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

      Makes sense, but isnt the complexity quadratic ?

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

        This confused me a long time.But the fact is O(n + m) multiply the complexity for the map's cost.You can spilt the procession into "iterate all the edges" and "iterate all the points",these are indivisual parts.So its complexity doesnt overcome the limit.Very interesting part for me.

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

    Sorry for my poor English, but I want to give an another idea for this problem.

    So if we want to know the best choice of group $$$1$$$, we must know that for each element in group $$$1$$$ we can choose which element in group $$$2$$$ to minimize the cost.For group $$$2$$$,we should know the choice in group $$$3$$$, for group $$$3$$$,we should know the choice in group $$$4$$$.

    Now the problem is how to make the best choice for each group. For one element, we can think that the elements which can't go well with it make some block point in number axis. The block point spilt the whole number axis into some intervals. So we can use some data structure to query the mininum for each intervals. I used Sparse Table to solve it :https://codeforces.com/contest/1487/submission/107467664

    This solution works in the time of $$$O(n \log n)$$$, if you choose the segment tree,this solution would work in the same time.

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

COPS IIT-BHU, has prepared a set of video editorials for the problems A to E of this contest.
Do check them out by clicking at This.
Hope you like the explanation

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

![ ](150927496-2854209298185767-1672263672911909316-n)

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

When will the ratings be updated? Its almost 5 hrs the system testing has been done.

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

Does Educational rounds have editorials?

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

When will the editorials be published?

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

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

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

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