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

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

Привет.

Некоторое время назад у нас в Самаре состоялась ежегодная олимпиада по программированию, и мы снова выкладываем ее в тренировки Codeforces. Тренировка пройдет в воскресенье, 17 апреля, в 11:00 MSK. Сайт clist.by говорит, что пересечений с чем-то важным в это время нет.

Раньше этот контест всегда был командный, но в этом году мы решили сделать его личным. Поэтому просим всех тоже участвовать лично. Так результаты будут наиболее адекватными.

Ну и как обычно,

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

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

Great :D

I really like the previous Samara contests :)

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

    No, it's Codeforces not Facebook. Tagging your friends won't appear for them in notifications.

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

      But what if it did actually work?

      I mean instead of messaging five different people on CF about the same contest, wouldn't it be nice and convenient if we could just tag them and they receive notification or something?

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

        I don't think that tourist will like it , as he's going to be fully spammed.

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

          Not if only the people in friend list of tourist are allowed to tag him ;)

          A person should get notified only if his/her friend tags him/her.

          PS — BTW I had no idea you replied to my comment till I revisited this page just now. :P May be a person should get notified if someone replies to his/her comment?

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

            You will get notified through your email. I think it would be more convenient to get notified here rather than in email.

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

Это рейтинговый контест?

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

Извиняюсь, а по каким причинам он стал личным? И заодно как это отразится на его сложности по сравнении с прошлыми контестами?

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

    По причине необходимости повышения его зрелищности.

    Сложность чуть упала, но не особо заметно. По-прежнему наиболее интересно должно быть фиолетовым и синим, а желтые должны решать все.

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

how to solve E?

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

Here is my game, on which the Bisection problem from this contest was based.

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

Can anyone show, how to solve "L"-Chess Match.

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

    We want to understand are there any permutations A of a and B of b such that the number of positions i with A[i] > B[i] is more than n / 2.

    Let's find the worst case(when the number k of such positions is the greatest possible) . It is easy to see in this case some of the k least numbers of b are less than some k numbers of a. So let's find k greedily step by step. Every step needs to find the least number x in b, and the least number y in a which satisfies a condition y > x. So k = the number of times when you can find such y

    For doing this you may use set or simple sorting
    Just do this algorithm with (a, b) and (b, a) and print the answer

    Your text to link here...

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

    I compared the n/2 + 1 smallest elements of A with the same number of the largest elements of B, element-wise (0th with 0th, 1st with 1st, etc.).

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

Could anyone tell me how to solve pro H and pro J? Thanks in advance.

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

    Solution H

    Spoiler
    • »
      »
      »
      8 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится +18 Проголосовать: не нравится
      In addition to problem H
  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится

    H. Let's have a look at some K. Let's create array c[] with c[i] = 1 if a[i] <= k <= b[i]. Then the answer for a query with group's size = K is the K-th index i with c[i] = 1 or -1 if there is no K ones in array. For more fast processing the queries(finding k-th positions/updating the cell) we can build a segment tree over the array c

    Now let's iterate over K from 1 to n. Before answering for a query K we must change c[i] to 1 for every position with a[i] == K (in segment tree, of course). After answering for a query K we also must change c[i] to 0 for every position i with b[i] == K. As you can see, implementation these operations keeps real array c in some moment K in our segment tree.

    Maybe code is the best explanation

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

    Another solution H.

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

    Also another

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

Can anyone tell me how to solve problem F ?

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

      Thank you :D

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

        Function for square of distance between points at the time 't' is a*t^2 + b*t + c. I don't think, that it is harder to find minimum of that function: max(0, -b/2a) — than understand and implement your solution correctly and without problems with precision.

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

how to solve I and M ?

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

How to solve Problem A-Treasure Island??

Got Wrong Answer in Case No-9. I use dp and dfs.

My code is here-17709718

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

    You can replace '?' with '.' or '#'. But you replace '?' only with '.'

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

      My idea is-

      1. If all land land position is connected and can be reached from any land position then others '?' mark can be replaced with either '.' or '#'.

      2. If all land position is not connected then we can replace '?' mark to '.' so that all land mark become connected.

      If we need every '?' mark to change in '.' mark to connect all land mark then we have a valid solution and If there remain some extra '?' mark that can be replaced with either '#' or '.' so this situation is ambiguous.

      And if we can't make all land mark connected after using all '?' mark then this situation is impossible.

      I am not sure my idea is correct or not. Please Give me some hints/idea or source code.

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

        You can run bfs\dfs from all '.' and mark all reachable '?'. If '.' are not connected then answer is "Impossible" else check for all marked '?': if you replace this '?' with '#' and all '.' are connected then answer is "Ambiguous" (you can replace this '?' with '.' or '#' so that '.' are connected).

        my source

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

how to solve D ?

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

    It can be solved by processing cities, ordered by descending their populations.

    You can use map for storing already processed cities by their coordinates.On each step you simply look and compare two cities by their distances to city, processing on this step: nearest from left and nearest from right.

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

How to solve I?

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

How to solve problem I?

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