Автор vovuh, история, 6 лет назад, По-русски

Привет, Codeforces!

30 апреля в 17:35 по Москве начнётся Educational Codeforces Round 43.

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

Этот раунд будет рейтинговым для Div. 2. Соревнование будет проводиться по немного расширенным правилам ACM ICPC. После окончания раунда будет период времени длительностью в один день, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

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

Задачи вместе со мной готовили Михаил awoo Пикляев, Роман Roms Глазов и Адилбек adedalic Далабаев.

Также мы хотим поблагодарить Ивана BledDest Андросова и Максима Neon Мещерякова за помощь в подготовке раунда.

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

UPD: Раунд будет содержать 6 задач вместо 7.

UPD2: Опбликован разбор

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

Rank Competitor Problems Solved Penalty
1 dotorya 6 150
2 I_love_Tanya_Romanova 6 276
3 uwi 6 324
4 nuip 6 327
5 dreamoon_love_AA 6 328

Поздравляем лучших взломщиков:

Rank Competitor Hack Count
1 hryniuk 66:-4
2 Aemon 65:-13
3 bitcoin 56:-2
4 uwi 57:-12
5 im0qianqian 40:-1

Было сделано 777 успешных взломов и 656 неудачных взломов!

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

Problem Competitor Penalty
A 300iq 0:00
B I_love_Tanya_Romanova 0:05
C readers3 0:06
D dotorya 0:26
E djq_cpp 0:21
F kraskevich 0:24

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

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

    I'm curious, but why is this round's ID so special? I meant, latest IDs are just 966 and 967.

    UPD: Round ID changed to 976 now. So perhaps it was a test or something.

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

Why contest http://codeforces.com/contest/967 is not showing rates? How long do I need to wait ?

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

Codeforces contests come at once

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

So many contests recently, thank you codeforces!

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

!!!

This round begins 23 hrs 30 mins earlier than CF#478. 2 hours contest plus 24 hours hacking end 30 mins after the end of CF #478 :)

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

Why CF have this tendention to increase number of tasks in 2 hour contests?

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

Happiness is having codeforces round in 3 consecutive days. :D

Thanks a lot to the Codeforces team and the authors. :D

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

Hi! Why isn't the round appearing in the contests page? (as well as in the "Pay attention" tab)
EDIT: Fixed!

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

Is it rated ( ͡° ͜ʖ ͡°)

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

Wish u lots of Heck(Hack)!!

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

This would be my first CF contest (mainly because this is one of the few contests which starts at a suitable time for me)! I'm just so excited!!

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

5 min delay

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

5 min delay! :3

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

Contest delays.

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

What the crap is with this 5 min delay ?!?!?! And yes, when the initial timer ran out CodeForces did freeze for me

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

How to solve D?

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

Priest OTK main, but cant solved E problem :)

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

Any idea of test 5 about E?

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

В задаче F используется алгоритм потока с ограничениями?

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

Any idea for test 10 in E?

Please tell me what is the wrong in my code.

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

Is solution to problem F flow with lowerbound? (and minDegree ≤ sqrt(n))

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

    Well, I think this might pass with some really fast flow algorithm.

    Intended solution is to build the following network: for chosen k, connect the source to every vertex of the first part with edge with capacity d(x) - k (where d(x) is the degree of vertex), then transform every edge of the original graph into a directed edge with capacity 1, and then connect each vertex from the second part to the sink with capacity d(x) - k. Then edges saturated by the maxflow are not present in the answer (and all other edges are in the answer).

    To solve it fastly, we might just iterate on k from its greatest value to 0 and each time augment the flow we found on previous iteration. Since maxflow in the network is at most m, and we will do not more than m searches that don't augment the flow, this solution is quadratic.

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

      But we can just use the same approach (iterating k and use flow from previous step) in flow with lowerbound solution, can't we? (I'm not sure about this)

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

      There's also other solution. Iterate on k from 0 to greatest value and gradually increment the capacity of edges from source/to sink by 1 (so it becomes k in each step). The answer is the saturated edges + any other edges that you choose to make degree[u] < k higher up until k. In other words, the edges from max flow cover 2 vertices and the rest covers just 1 and the answer is k * (n1 + n2) — maxflow.

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

Any idea for test 30 of problem E? I have wrong answer on test 30 T_T

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

Is this approach for E correct?

If you are going to double the health, then all such operations must be done for the same element

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

How to solve C? Binary search?

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

    I solved it with sweep line algorithm and some optimisations.

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

    Sort the segments if starting of any 2 elements is same, they overlap if end of i >= end of i+1, they overlap Check using the given conditions

    Mine passed the prelim cases, lets see how it goes.

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

    You may sort the pairs of {L,R} in non-decreasing L's, if two elements have the same L value, the element with bigger R get the smaller index. By sorting, you can check the R values only (because you are sure that the L value of the current element is bigger than or equal all previous elements) and if you found an R value that is smaller than the previous R value, then you've found the answer (which is the element we are currently at and the one directly before it).

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

    Sort all segments by their left border and keep track of the segment with the greatest right border on prefix. Now when you are considering segment i, all the previous ones have less left border and you only have to check whether the right border on the corresponding prefix is no less that yours.

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

    You can store the pairs as(L,-1*R) and then sort it. Then keep track of the max value of R encountered while traversing the array If maxR >= curR then print both the indices

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

Why can't we in E use the first spell only for one creature? When we are using the first spell it has sense only when hp will be bigger then dmg and if we use the first spell for two creatures then one of the creatures had bigger dmg do we could use first spells from the one with smaller dmg.

If this approach is correct can someone tell me what is wrong with this submit: http://codeforces.com/contest/976/submission/37772123 ?

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

Try to hack my B

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

How to solve D?

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

How to solve E ?

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

I seem to have gotten the right idea for E but my solution did not pass. I am not able to find the mistake I have made. Can someone please help?

http://codeforces.com/contest/976/submission/37772350

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

Hi to everyone! Could you tell me some tests with marginal situations of E problem?

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

Does somebody know why this submission for E isn't working on test 10?

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

why is it that in problem F, calling a maxFlow algorithm for every degree <= minDeg is within time constrains, shouldn't it be O(minDeg*V^2*E) — if we use Dinic for example.

UPD: I think this maybe because the graph can be very sparse, if you have for example all 2000 vertexes on both sides then m = 2000 implies that minDeg <= 1, so only one call to maxFlow will be needed. On the other hand, I think in the worst case minDeg will be O(sqrt(m))

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

When will our ratings take affect?

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

when will system testing begin

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

Can somebody tell me will our rating change before round #478? (^:

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

    Most probably yes. They have finished the system testing just now and it is hardly a matter of time that rating changes will start reflecting. Since round 478 is still around 5 hours away so most probably you will be able to participate in div.1 if you have made it to div.1 after system testings.

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

    I hope yes:)

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

    Yes

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

It is system testing now. Why the result has been published?

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

Где разбор?

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

Спасибо авторам за задачи :) Особенно приятно было читать условие задачи E, вспомнилась механика одной очень хорошей игры :D

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

hacked my own friend's solutions hahahaha

EDIT-One of them down voted me :P

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

Educational rounds are really adventurous. Take one full day for hacking. In case ur code survives system testing your anxiety until rating update is there.

by A Div2 Coder

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

When does it rating change? )sorry to my poor English

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

I'm new to cf, can anybody explain me the hacking system.ty in advance.

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

что случилось? почему рейтинг не обновляют?

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

    Мне вот интересно, что будет с теми, кто наберет 1900+ и перескочит в Div1, но уже зарегистрирован на раунд 478 (Div2 only). Может решают эту проблему?

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

I have a question. I will be candidate master in this round.but rating doesn't change now.if I take part in next round, i am a div1 participant or a div2 participant?

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

    I think it depends on the moment you press "Register". If before rating change, you will be counted as a Div2 participant nonetheless.

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

Nice, about time with the rating changes :)

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

    Firstly, never use implicit cast but use static_cast instead. Secondly, you cast long long to double which leads to undefined behavior. E.g. the same code gives the correct answer on C++17 compiler. Try to cast it to long double instead.

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

      Why casting long long to double causes undefined behavior ?

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

        To be more precise, it causes implementation defined behavior (depends on the platform and/or compiler version). Nevertheless, double usually has only 53 bits of mantissa, which is not enough to store every long long integer, and you definitely should see a compiler warning if you haven't disabled any. Why implementation defined? Because each compiler acts in a different way. So depending on the compiler version, optimization level and other factors you can get different results, e.g. possible auto-conversion to long double and vice versa.

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

Отличные задачи!