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

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

Привет, Codeforces!

В 17.05.2018 19:35 (Московское время) состоится очередной раунд Codeforces #484 для участников из второго дивизиона. Традиционно, участники из первого дивизиона приглашаются поучаствовать в соревновании вне конкурса. Как обычно, обратите внимание на необычное время начала раунда.

В этот раз задачи для вас готовили я и Андрей API Пикас.

Хотелось бы поблагодарить Николая KAN Калинина за помощь в подготовке задач и координацию раунда, Михаила MikeMirzayanov Мирзаянова за замечательные системы Codeforces и Polygon, а также Кирилла kittylover Самелюка, Николая Apollon76 Пермякова, Дмитрия Krainov_Dmitry Крайнова, Андрея GreenGrape Райского и Алексея Um_nik Данилюка за прорешивание задач и ценные советы.

Участникам будет предложено шесть задач и два часа на их решение. Разбалловка будет объявлена позднее.

Желаем участникам найти интересные задачи, успешных попыток, взломов и высокого рейтинга!

До встречи!

UPD Разбалловка 500-1000-1500-2000-2500-3000

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

  1. Kotori_Is_My_Wife

  2. vosptu

  3. ez_zkj

  4. relativity

  5. iordache.bogdan

А также победителей двух дивизионов:

  1. Claris

  2. Benq

  3. Kotori_Is_My_Wife

  4. kmjp

  5. vosptu

UPD3 Разбор будет опубликован завтра.

UPD4 Разбор

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

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

Six task in two hours. I think enjoy it all.

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

Твой прошлый рануд был интересный, верю, что и сейчас что-нибудь прикольное будет)

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

Is there div 3 and is div 3 rated?

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

Great :). You could fix timeanddate.com link to make it display time in user's timezone. Take a look on Mike's comment: http://codeforces.com/blog/entry/59322?#comment-429178

Displayed time screenshots of #483 and #484:

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

Yeaaa! Round by my favourite problemsetter! I waited it so long. <3 <3 <3

I think, I can become Candidate Master tomorrow.

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

Thanks to all, who have create this contest !!! for giving us opportunity to test our skill . such a big platform

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

Third palindrome round in 2018 !!

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

...

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

I smell a lot of hacks

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

Q. Why do you start blushing when a new Codeforces round is announced?

A. It turns me Red. ^_^

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


Reading comments be like...

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

is it rated for purples ?

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

Should have a contest on yesterday. 13,14,15,17....why missed 16??

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

123

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

What about for Div 3 members?

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

    Most contests in Codeforces:

    1) Div.1 + Div.2: Candidate masters and higher (1900 and higher) will be in the first division while experts and lower (lower than 1900) will be in the second division

    2) Div.2 Only: Candidate master and lower (lower than 2100)

    3) Div.3: Specialist and lower (lower than 1600)

    So please stop commenting the same question every contest.

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

А может всё-таки запотеем на претесты и без взломов?

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

    Когда-нибудь люди поймут, что поймать в семи-восьми претестах все ошибки, которые способны допустить шесть тысяч человек, решительно невозможно :)

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

      Нет взломов не от слова совсем. Нет взломов, значит в топ не попадают парни с +30)

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

      А мне кажется, что возможно! Можно же не обязательно брать фиолетовых+ чуваков тестировать раунд) Берите зелёных, бирюзовых, синих. Чем меньше опыта, тем больше ошибок) Так почти все случаи и найдутся

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

Как обычно, обратите внимание на необычное время начала раунда.

Как же я обожаю эту фразу.

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

Wish high ratings to all.

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

I hope this round won't be like that 1vldm8

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

better starting time for Bangladeshi contestant....

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

Can't open problem C and D. Showing Error !!

»
6 лет назад, # |
  Проголосовать: нравится -12 Проголосовать: не нравится
Комментарий удален по причине нарушения правил Codeforces
»
6 лет назад, # |
  Проголосовать: нравится +66 Проголосовать: не нравится

How to solve F?

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

    If we look at the dfs tree of the graph:

    • If we got any backward edge (an edge connecting a node to one of its ancestors) then the answer must be one of the nodes between the two endpoints. If there is not such edge then answer is -1.
    • If we got another backward edge then we need to find the intersection (or remove nodes from solution which are ancestor of the other node or are not ancestor of the current node). For example, 1 -> 2 -> 3 -> 4 is a cycle, and 2 -> 3 -> 5 is another cycle. Both 4 -> 1 and 5 -> 2 are backward edges.

    • If we got a cross edge (edge connecting a node to another that is neither its ancestor or descendant) then if the other node is in cycle and topmost node of the cycle is a parent of the current node, we need to erase the nodes that are neither parent to the current node nor descendant of the other node. For example, 7->4 is a cross edge.

    Submission as a reference: 38382900

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

      Hi there, I am struggling hard with this problem. So I studied your code quite a bit, and found a mistake in it. Try the following test case:

      6 9
      1 2
      2 3
      3 4
      4 1
      4 2
      3 5
      5 6
      6 4
      1 6
      

      Solution should be 4, but your program answers -1.

      The last edge 1->6 in this test case is a cross edge. So you have to delete all vertices on the cycle 1->2->3->4->1 that are anchestors of 6, but not of 1. Finding the lowest anchestor of 1 on the cycle works (it is 1 itself). But finding the lowest anchestor of 6 doesn't work, since you argument with the height h of 6, which has nothing to do with the ancestors.

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

How to solve problem D?

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

    You can brute force for all posible k using sets in O(nlogn).

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

      what is the test 5 ?

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

        I used co-ordinate compression. I got WA TC #5 when I was printing K in terms of the compressed value instead of the real value.

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

          I got WA on test 5 for a different reason.

          My answer: 57209037

          Judge: 45567032

          My algo iterated a values as candidates for k. When a is sorted by size, these values are consecutive in the input:

          57209037 (found best solution at this value)

          45567031 (found worse solution at this value)

          Obviously, the best solution can also be found at 45567031+1.

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

        If anyone needs complete test 5 input, I've put it here: https://pastebin.com/vHuv6LE4

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

      What is stored in the sets? Also... Brute force requires to iterate through the whole array right?

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

        We can store lengths of locations and when they are reached, with a array or bst like std::set or std::map. To do this we can sort the sequence and enumerate k from 1 to n, using disjoint sets.

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

      Can you elaborate please?

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

      based on this we can simply use an array instead of std::set, thus we can do this step in O(n).

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

    And of course k can only be equal to a[i] + 1

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

      I got the k=ai+1 part during the contest but can you tell me about how to brute force ??

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

        I have one set to store segments of elements less than k and one multiset to store lengths of all segments in first set. Then i add all a[i] from the smallest to the biggest, where current k = a[i] + 1. When you add one there're three scenarios: it forms a new segment, it unites with one segment, it merges two segments together. I think it's clear how to do updates and how to keep multiset of length.

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

          Oh thanks I get it.

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

          Alternately, start with the segment [1...n], and add a[i] from largest to smallest. This way, it's guaranteed that the only operation happening is breaking up an existing segment, which makes implementation easier.

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

        So when at some step segment set size is begger than it's sizes at all previous steps and when all elements in multiset are equal I update the answer with a[i] + 1.

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

      I thought of this, forgot to implement it because the samples didn't need it, and managed to implement it with about 10 seconds to spare in the contest.

      ...Needless to say, I wasn't able to submit in time :(

      Ah Codeforces, thou art a cruel mistress...

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

    Maintain a dsu of active indices and process the indices with increasing order of values. At each step, let cur_k be value + 1. Check if neighboring indices are active and accordingly merge them. Also maintain the count of total active indices for a given size of set. Update the answer if the current size is equal to total active indices.

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

    I took 30mins to solve it. Authors need to be more cautious before preparing a problem. :(

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

    striver_79 try to solve problems rather than searching for problems

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

      haha, if I was to search for the problem, I would have got all the pretests passed in 5 minutes. I tried for an hour, but when I did fail for it, then I was searching for the DFS part when I came across it. Learn to observe before saying something. :)

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

        Looking for the dfs part and then came across that nice explanation btw what are you looking in DFS. "WHAT TO OBSERVE". I also type DFS in google but I didn't came across that question maybe your browser is a legendary one.

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

          I do not owe an explanation to you that is for sure buddy. And stop blaming someone for pointing out a link which seems similar. :) I guess you learn everything without googling. You got so much of inner talent :)

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

Problem E can be solved by the fact that this rectangle can be mirrored adjacently on the coordinate plane.

No, I didn't solve it.

I've done a similar problem in Google Foobar. If I had been given 40 mins I could've solved it. :(

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

What is the 6th pretest in C?

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

Problem C is available at Hacker Rank: Your text to link here... . Check this out..

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

I read "connected components with equal size" instead of "even size" in C. Yikes

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

Feedback:

C: nice

D: A bit ambiguous, I needed two clarifications to understand it.

E: The mirroring trick is very standard. I think I've seen a very similar (maybe the same) problem in uva.

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

    C was a direct copy from geeks for geeks

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

    Mirror trick? Can you say sth? I solve it using Chinese remainder theorem.

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

    Do you know if there's a name for the mirroring trick? I've seen a solution that used it in the past, but I wasn't able to understand it then. I'd like to find more information about it and learn it now.

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

      just consider each side of the table as a mirror and copy the table based on its picture in the mirror. So anytime the ball hit the side it enters the new table and continues its direction.

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

        I don't understand what algorithm follows this. You calculate the intersetcion point of rectangle and a straight line. If you hit the origin or a corner, you are done. If you hit the wall, you reflect the whole rectangle and keep going.

        You repeat the above 10^9 and tle.

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

          The point of the reflection isn't to simulate the process: that can be done without the reflection at all. The point of the reflection is:

          1. You can now travel in a straight line

          2. You get generalized coordinates for the corners: for example, using the labeling in Morphy' picture in the other comment, point A will have coordinates (2mk, 2nl) for integers k, l.

          You can get similar generalized coordinates for the other 3 corners, and then it's simply checking whether integers k and l exist such that the point given by them lies on the line you have, in the direction you want.

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

            Can you please provide a resource link to learn it? Thanks in advance.

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

              I'm sorry, but I don't have an online resource for this sort of thing.

              Given the context, I'm pretty sure that there'll be a few problems of this type discussed on AOPS, so look there maybe?

              To be honest, this is my first time seeing the reflection being used in a coding problem. I've only used it in maths problems before, but it seems like a nice Olympiad problem trick, so AOPS seems like the place to look.

              I'll look around a bit and see if I can find something more concrete.

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

              This link might be helpful for the proof and solution of diophantine equations.

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

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

    I agree with you and saw a couple of problems like E. (e.g. in Google foobar) I'm wondering why did I read it at the end of contest! :-/

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

I used tree dp to solve C but now i find out that there's some simple solution -_-

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

Очень расстроила задача F. В ней всего в одном месте неявно указано, что граф ориентированный («дороги односторонние»), после чего никаких упоминаний или рисунков со стрелочками или любых других намеков на ориентированность нет. И тесты из условия тоже очень легко воспринять за неориентированные, причем код для неориентированного случая их проходит. :(

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

    Дороги в Брагинске односторонние

    будут продолжать ездить по односторонним дорогам

    количество перекрестков и односторонних дорог

    начало и конец i-той односторонней дороги

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

      Перечитал. Действительно, все так, не знаю, как я все это просмотрел. Приношу искренние извинения составителям.

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

So are you sure what you want us to find in D is what D's statement says?

Thus, in the sequence of n days we can find consecutive nonempty segments when the shark traveled the distance less than k in each of the days: each such segment corresponds to one location.

Shit in bold's true but it it's not true that each location has a corresponding nonempty set.

Now getting back to what the problem asks for:

Find such integer k , that the number of locations is as large as possible.

And at the same time, what you want us to do is find the k which maximizes the number of nonempty sets, not the number of locations.

Even after the announcement, which was too late anyway, nobody bothered to actually update the statement.

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

    This is because if a shark travels 2 days in a row, he will still be at a new location on the day in between, correct?

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

    After reading the problem statement I thought the answer to this test case 8 1 2 7 3 4 8 5 6 should be 0 as it satisfies all the conditions asked i.e 1) the shark was in each location the same number of days, 2) the number of locations is maximum possible satisfying the first condition, 3) k is smallest possible satisfying the first and second conditions

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

      I have the same confusion regarding this problem (but not anymore). Let me help clarify this. Assume the answer is k, one location is counted as non-empty consecutive segment which every number in it is strictly lower than k.

      For first sample case, if the answer is 7, the number of location is 3, that is {1,2}, {3,4}, {5, 6} and valid because each segment size is two. If you choose 0 as the answer, the number of location is zero. So there's a better answer than 0.

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

Happy Ramadan holiday to all. I wish happiness and health to everyone.

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

Было бы здорово, если б люди, знающие задачи, не сабмитили код во время раунда. А то всякие с 300icq интеллекта засылают верное по F на 4ой минуте, после чего создается стойкое ощущение, что можно пихнуть хрень и кода должно быть мало.

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

    Задачи раунда я до начала не знал, если ты об этом

    Ну и я хотел написать раунд полностью (а зарядка ноута, как оказалось, не хотела), и не видел смысла писать решение и так известной мне задачи

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

      Ты за 4 минуты 3-4 экрана набираешь? Мое почтение!

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

        Тебе же написали, что это известная задача

        Вроде несложно догадаться, что ее просто скопипастить можно

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

This statement didn't exist at the beginning of the contest. My solution was hacked because of it. and there was no clarification about it!!!!!!! AGrigorii [ ](Ca)

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

    it did exist

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

    Actually we missed initially that the note was incorrect for n = 2. The mistake was fixed a few minutes before the round, as soon as MikeMirzayanov spotted it, and the update was pushed from Polygon to CF. It takes some time, but for me the statement opened a minute before the contest already contained the fix, so I decided that everything was ok and I did't have to make an announcement. It turned out that for some people the old, cached statement opened without the fix. Luckily almost everyone understood what we meant correctly.

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

      Till I submitted my solution ,the fix didn't exist. I wrote my solution based on what I read in the statement. It wasn't my mistake.

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

      You can`t re-test only A problem without test with size = 2? I think it would be fair

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

      So this is over and my rate decreased beacause of a mistake which is not mine.

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

        Stop crying over dumb shit. Mistakes happen and this contest is not the end of the world.Also its just -20 which can be recovered very easily.

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

          As for me, this worsened my result by 45, but I totally agree that this is just a rating, but it's not very pleasant either

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

A question copied directly from geeksforgeeks, wtf ???? Contest should be unrated.Its a big disgrace.

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

    The practice shows that it won't be unrated. There was a case when absolutely the same problem appeared twice even on codeforces itself but the round was rated.

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

      If I am not wrong it was in an educational round, in which the ideas can be common. And it did not affect many div 2 coders. I might be saying this since I performed bad in the contest. But still C was just google and first link and it shouldn't be the case.

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

        I think there were plenty of "just google and first link" cases too. But still I think we should let coordinators decide whether it's fair or not.

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

        I have seen many times(I guess at least 3) where exactly same problem was in other contest, but mostly all of such contests were rated.

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

Was not able to open all problem statements in one window :( Bug

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

How to solve C?

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

o.O

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

What topic should i learn to solve C div2?

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

Almost same as today's Problem C Is there any difference conceptually ???? May be it is not what the contestant expect from the problem setter..

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

Капец в А там же написано было, что не может 1 и последнее место быть соседним, а потом только же добавилась приписка, что n != 2?? Так же не честно... Если я не прав, напишите.. странно.. разве я мог не увидеть..

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

    n = 3, 101, вот тут 2 единицы соседними не являются

    n = 2, 11 а вот тут являются потому что n = 2(ваш КЭП)

    Т.е условие говорит что первое и последнее место являются соседними только в одном случае — когда n равно 2.

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

      Изначально, насколько я помню условия что первый элемент и последний не соседи было написано так, а потом добавили что это не так при n == 2

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

      Не знаю, зачем ты это объяснил, это очевидно. Проблема в том, что пояснения про случай n = 2 не было в начальном условии, а когда оно добавилось, не было кляра. Конечно, глупая описка, но кого-то могло ввести в ступор.

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

чё-то изи

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

    сейчас бы падать, на как ты говоришь "изи" контесте. А так контест очень даже не плох

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

How to solve C if it would have been a graph with cycles ?

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

    tree hasn`t got cycles

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

      I know that. I am just asking how would one go about solving the problem if it would have been a graph with cycles as the approach used for solving the tree one will not work here.

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

        Sorry, I did not understand correctly what you mean

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

        I may be wrong but in case of undirected connected graph we have to consider only those edges which if removed results in more than one connected component otherwise clearly if removal of an edge does not divide the graph then answer depends on n is even or odd. Now for the previous one you can have a look at bridge in a graph --> https://www.geeksforgeeks.org/bridge-in-a-graph/ Removing such edges and doing the same what we did in actual C question should do the thing.

        But Edges might be of order which does not satisfy the constraints if n is 1e5.

        By doing the same thing (which i wrote above) i mean that edge should be removed only if it divides two parts in even number (each).

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

          The approach seems fine but I think finding out Bridges and removing would give "minimum" number of edges required for deletion and not "maximum".

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

            No removing bridges does not govern whether we get minimum or maximum edges. When i say that you remove edge only if it disconnects the graph and both sides nodes should be even. So automatically all the edges which satisfy this property will get counted and that's what we did it in given C we count all those edges which divides the nodes into two even halves. Please correct if i m wrong !!

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

      in case of a connected graph ???

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

About the choice of wording in condition 1 of A

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

In Question B why doesn't 3*nlogn pass the test cases. I tried using maps in c++ but it is showing time limit exceeded in test 45 . Can someone point out mistake in my code : Link

  • »
    »
    6 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    while(used[cnt2]==1)
    cnt2--;
    

    This part doesn't looks like O(1) or O(log n). I think, it's O(n) at worst case (because of "cnt2 = cnt1;" six lines higher).

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

Yay, I became master, but sadly only because of div2 rounds.

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

    What is the difference? Master is master. If you don't want to participate in div 2, then wait for div1...

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

      well actually its opposite, there are some purples that skip div 1, because they don't want to be beaten up by reds and yellows and join div 2 to compete with blues instead.

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

    I don't understand why everybody is complaining and thinks that it would be easier to get to 2100. The only true thing is that there will be more opportunities to get there. It doesn't mean it would be easier. If you don't deserve 2100 you won't get it, one way or another.

    For example I already managed to lose a lot of points in div 2 contest on Monday. And today I was 122. If there were no violet coders, I would have been 25'th which would have given me much more rating.

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

      Lol You don't understand? Before this shit revolution, to get Master(old) you need to most likely solve 3 probs in Div 1 which is equivalent to all div 2 problems. Now get just good ranks which in most case is possible with just 4 div 2 problems. As you can see in this round, 370 officially solved 4th hardest, you think thats good enough for someone Master?

      "I don't understand why everybody is complaining and thinks that it would be easier to get to 2100" Because it actually is faggot. If you don't understand, then compare how many users have got there maximum rating in past div 2 only rounds.

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

        "to get Div 1 you need to most likely solve 3 probs in Div 1" — makes sense. Sorry about my previous post.

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

    You've became at least, not like me :D (9 points)

    Congradulations!

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

      At least you have a chance to participate to next Div2 round, not like me :D (passed to master with 11 points).

      Congratulations!

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

It looks very strange that O(nlogn) solution for D works without any used memory: 38374872.

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

    That claim about F is totally ridiculous

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

        The Quora answer is wrong and comments don't seem to give any hint to actual solution.

        As for the Polish problem, the translation shows that it is a harder version of Problem F. However, it isn't possible for problem setters to verify that their problems don't exist even on non-English sites.

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

        Yes, it's the 4th time that I came across this problem.

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

      It is not. I didn't realize this and now I checked that my incorrect solution to kon (9/10) is accepted after 2 small modifications (for 2 or more disjoint cycles and for empty list of cities).

      Though I am not sure if I would have been able to figure out the first one during the contest...

      Anyway, top 5 has gone...

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

    Sorry but I have to say that CF won't care about such a thing!

    Sometimes CF copies exact problems from itself though.

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

      It's not copying if the second setter didn't realize that the idea for the problem was already used before.

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

speed of light coder !! ****

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

I think systests on D are very weak. I found a big mistake in my code after submit but surprisingly gave me an AC. My AC code: http://codeforces.com/contest/982/submission/38384511 A simple test case when my output differs from another AC submissions: 11 7 9 8 100 1 2 3 200 4 5 6 There something invalid in this input?

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

In Problem B What if the number of extroverts(1) at any point becomes greater than number of introverts(0)? Many solutions will fail then ![problem:982B]

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

    It is mentioned in the problem statement itself that there is always a suitable seat for an extrovert, So no such case will occur.

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

    It is guaranteed that the number of extroverts equals the number of introverts (i. e. both numbers equal n), and for each extrovert there always is a suitable row

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

Can someone help me in understanding D ...??

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

    For each different k[i] = a[i]+1, you check the size of all the contiguous days with a distance covered strictly less than k[i].

    You go through all the a[i] in ascending order.

    if a[i] does not have a neighbour lower than him, it creates a new contiguous day sequence of length 1. Then, you merge it with his neighbour(s) (if they are lower than a[i]), which destroys their sequence and creates a new sequence of length 1 + total length of the sequences of the neighbours. It's important because you need to keep track of how many different lengths of sequences you have at all time, cause you will need it at each step.

    To keep track of how many different lengths of sequences you have after each a[i], you can create a table that tracks how many sequences each length has, and a variable that tracks how many lengths you have (that you increase by one each time you insert a sequence whose length is not represented yet, and decrease whenever you remove the last sequence of a given size). If there is only one length in the table, then you know that the number of sequences for k[i] is (number of distances <=a[i]) /(only length of sequence represented).

    The answer is the minimum k[i] that leads to the maximum value of this ratio. You can do the merge with an union/find, making the merging a O(n*log(n)), and computing the ratio each time can be done in constant time, leading to (I think) a solution in O(n*log(n)).

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

AGrigorii When is the editorial gonna be published? If it's already published in Russian, please do provide the link. Thanks

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

I found a surprisingly simple solution for F. The key observation is that if you have a node with an outdegree of 1, you can delete that node and push all incoming nodes to the successor (with a special case for self-loops). This process can reduce the number of edges if an incoming node was already pointing to the successor node.

As an example, node 3 in the image below can be deleted since it has only one outgoing edge:

Which results in:

Note that this reduced the outdegree of node 1, making it now eligible for deletion.

If you have more than one node remaining after this reduction, then the answer is impossible. I haven't tried to prove this, but it resulted in an AC submission. :)

For each node, it is essential to maintain an unordered_set for incoming and outgoing nodes to detect duplicate edges. This makes it slightly slower (due to the set operations), but it's fast enough to pass in C++ (albeit not in Java, from my experience). My accepted submission: 38409568.

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

    I thought about a proof of your solution, and I think it is correct. If anyone find any wrong with it, just point out the wrong point.

    The first part is about the validity of deleting the point with one out-degree. We can think about a point u that satisfies the requirement and we call v is a point that have a direct edge to u. We can easily find that every circle that pass the edge u-v must pass the point that u can only arrive at. So we can think u is useless and delete it from the graph (of course it contains the process of changing some edges).

    The second part is about why the answer is impossible when there are more than one point remained. Now, the graph satisfies every point has at least two out-edge, of course we can remove arbitrary out-edge to make every point's out-edge is two. Then we build the dfs tree of the graph, and it is a binary tree. We only need to discuss about the out-edge of the leaves. We assume that this graph is valid for answer. Then we need to construct the out-edge of the leaves by a optimal way to make the graph is valid. So we can first make every leaf link to the root, and the other out-edge link to the next leaf in a way you like. But we will find that one leaf can't make another link because it wouldn't be valid no matter where it connect to. So we can prove this part.

    This solution has a drawback is that it can't output all the points that satisfy the problem. But it realy easy to type.

    (If there are many grammar errors, please don't blame me. Because my English is realy not good.)

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

I did not manage to solve div2-C using Python 2. My submission 38369140 got runtime error. I think the issue is recursive calls. Is there a trick in Python to get this code AC?

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

Who can tell me what's the meaning of 'even size' in Problem C. The 'even' means equal? or %2==0??

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

Request: Please post the editorial link with problems for this contest. Had a hard time to find this post to find editorials.