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

Автор ibra, 9 лет назад, перевод, По-русски

Привет Codeforces!

Как вы наверняка уже знаете из предыдущего поста, Bubble Cup это соревнование по программированию организуемое силами Центра разработки Microsoft в Сербии (Microsoft Development Center Serbia) на протяжении последних 8 лет. И финал этого года приближается!

В этом году у нас появилась замечательная идея провести зеркало этого финала на Codeforces! Мы хотели бы поблагодарить MikeMirzayanov и команду Codeforces за замечательную платформу, а также их поддержку в подготовке и проведении.

Соревнование начнется 6-ого сентября в воскресение в 11-00 утра (по Московскому времени). Длительность контеста — 5 часов, будут использоваться правила ACM ICPC. Это будет командный контест на Codeforces, между командами (1-3) человек. Количество задач (7-10) будет объявлено позднее.

Контест подготовлен силами работников MDCS и участником knightL. + спасибо участнику Milanin за помощь в тестировании.

В виду того что правила этого контеста не совсем обычны для Codeforces (и в виду того что зеркало мы проводим в первый раз) контест будет нерейтинговым.

10 Лучших команд получат футболки (каждому члену команды) +10 футболок будут разданы случайно командам из топ-100.

UPD обратите внимание на то, что мы обновили максимальное возможное число людей в команде

Разбор, результаты и пост про футболки будет немного позднее

Ссылка на пост с результатами и разбором

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

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

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

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

it's in gym?

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

    no it will be a usual contest, just not rated. Will be added to "Contests" very soon

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

      why unrated?

      I l<3ve rated contests.

      :( after about 1 week, we have an unrated contest :|

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

        I will tell you a secret: I love rated contests too (I guess everyone does). I was disappointed when heard that we will have to make it unrated too. But this contest is really very different from usual contests (team contest, 5 hours, ACM rules, ...)

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

          :( so, no way?

          it isn't possible to make it rated?

          what is the problem?

          yeah, I know, it's unusual but I think it isn't a big problem.

          if some one can solve 2 problems in 2 hours, he can solve 3 or 4 in 5 hours, and the team isn't problem, any one can have a team. he can join a good team!!.

          and ACM rules are not so unusual.

          if there is a way that make this contest rated, please do.

          great thanks,sorry for my bad English.

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

Should a team use only one computer?

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

    yes (because onsite competitors will)

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

      Ok, thanks for clarification.

      Btw. onsite teams consist of 3 people, not 1-2. So argument "because onsite competitors will" is not so strong.

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

        Also onsite competitors are, of course, in one location and also we will not be competing directly against them anyway (so why should their rules restrict us when our team members might not be in the same place?). Perhaps it would be best to do what vk cup finals mirror did:

        "Note that during the round the team is allowed to use only one computer. This means that you may code/use console/succeed in solving problems in any other manner by using only one computer at time. The only thing that is allowed from two computers is reading the statements."

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

5 hours and just 7-10 problems? It seems to me that this problems should be really hard, or some teams can close problemset very fast.

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

    We expect that only the strongest teams may close problem set before end of contest (although the may not)

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

knightL — russia, Simferopol?????? Seems like this guy hasn't visited geography lessons, because of his addiction to problem solving

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

Would you show picture of special T-shirts before the contest?

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

I need upvotes PLZ :_(

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

I want to participate in this competition with a friend, how does it work? We both register and then only one of us logs in and we use one laptop with only one logged in session?

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

Would someone mind elaborating on the reasons that the Bubble Cup mirror will not be rated? While I still plan on participating, I find I tend to enjoy rated contests more than un-rated ones, because I feel that more is at stake.

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

    +1. Rating is a cool motivation and in my opinion such unusual contests should be rated to. It won't be similar to CF-round but what's wrong with that?

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

      Mr. Mike can play a trick by announcing them as rated first and then turning them unrated later! Enjoyment should not be put to stake!!

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

    Good Idea! Since we don't have any other CF round coming, I would support that

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

    I don't like weird rated contests, they are doing weird things with ratings. Especially when all those 1 and 2 persons teams are included. Moreover it is long, 5 hours. Pretty far from typical CF round, I wouldn't appreciate having it rated. Moreover for me it will be 1-6AM, so I will probably participate, but will go to sleep in the middle, probably I'm not the only one, who can participate in a proper subset of those 5h, rating this will prevent me from participating or maybe I will use troll-account which you also don't want to :P.

    Another argument could be that this contest will not be "Codeforces approved" in a meaning that CF staff has not anything to do with preparing problems, that's kinda like 'outsourcing evaluating own rating', not something company would like to do :P. CF rating should be based on CF-created contests.

    In terms of motivation you have T-shirts here.

    EDIT: Little clarification, by 'weird' of course by no means I meant something negative. I just meant that there are many factors which cause that this contests is significantly different than typical CF round.

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

      Totally agree with first paragraph.

      About second: as far as I know (this is second contest I participate in preparing of) Codeforces team do not help to prepare problems, mostly reviewing, translating, advising. From this point of view, you can be sure, problems were reviewed by Codeforces team and approved.

      About T-shirts. I haven't seen T-shirts competitors will get, but I got mine as author and it is awesome — probably the best T-shirt I have ever got from competitions (I guess/hope competitiors' T-shirts will be almost the same =)

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

      Well, how about keeping an option for out-of-competition for everyone? That can prevent troll-account, I think.

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

      no one say you must participating in this contest just

      go to sleep and drinking milk

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

after 2 week we have a contest. LOL!!!

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

wish winnig t-shirt for you

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

Gosh ... I love CF's T-shirts, wish winning T-shirt for you!!!

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

Right now, I couldn't register for contest as a team, only as an individual. Am i missing something?

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

Nice! so can i join individual or only teams ? and when will be the next round? Thanks

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

How difficult this contest will be? Will it be in the same difficulty with a Div1 contest?

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

Shouldn't it be "Bubble" instead of "Buble"? (in contests page)

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

There were a lot of questions about how difficult this contest will be.

Well, I am not sure =). It will have both difficult and easy problems, both for Div1 and Div2 participants. I think couple of top teams may solve all the problems before time ends.

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

Поступает много вопросов о том насколько сложным будет контест.

Ну, я не совсем уверен. Будут и легкие и сложные задачи, и для участников Div1 и для Div2. Возможно несколько самых топовых команд решат все задачи быстрее чем за 5 часов.

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

По-моему лучше было бы сначала провести контест, и в случае сильных сбоев уже сделать его нерейтинговым. Хотя не помню на КФ не одного рейтингового контеста длительностью более трёх часов.

Хотя зная заранее, что контест нерейтинговый, команды не рассчитывающие на футболку могут начать действовать по тактике "сдать задачу с 50 попытки — нормально", что в свою очередь может привести как раз к сбоям работы КФ.

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

are the problems sorted by their difficulty ?

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

Порешаем :)

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

Why top rated team has 3 members ?

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

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

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

Автокомментарий: текст был обновлен пользователем ibra (предыдущая версия, новая версия, сравнить).

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

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

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

What language can we use? only C++, C#, and Pascal?

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

How do I compete if my team member is in a different location?

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

Will the printed version like pdf be available?

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

Hey,

I registered as a team, but the problem is that we live far away from each others so each member will read and solve problems on a standalone machine, but submission's will be sent from one machine only.

Is this ok with contest rules ??

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

    It's not about submitting from the same computer. It's about working on only one computer in each moment. So not being in the same place is ok as long as you communicate with each other and there is no moment when two of you work with computers at the same time.

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

I have one question :

It's certain that all top 10 teams won't contain three members. Will you give extra t-shirts for top 100 participants ( 30 — all top 10 users) ?

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

Is there any editorial after the contest? Thank you.

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

Sorry, I just left my computer in the hands of some friends of mine :/ You can downvote radoslav11 or JustInCase btw...

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

Точное количество задач?

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

If its a team contest, that too 5 hours long, it is not fair to everyone if the contest is rated. On a lighter note, as far as motivation goes, not getting a negative rating change is enough motivation for me.

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

Where can I choose my Bubble Cup t-shirt's size?

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

What's wrong with this countdown timer? :)

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

It's pretty bad that it is rather impossible to get a penalty for wrong solution for problem D. There is only one test there...

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

There is a good way to win 3 thirts.. Just make 2 new accounts.. And participate with them..

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

I couldn't solve anything ;_;

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

Just woke up now :/

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

Editorial?

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

How to solve F? Especially interested in O(n) solution.

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

    All possible locations consists of points {initial point, Lstart points, Lend points}.
    To obtain best result, in each turn it is sufficient to move to one of the 2*n+1 points suggested above. So, this dynamic programming works:

    dp(i, j) = minimum summed cost, if we already made i turns, and we are at point j.

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

      how to recalculate this dp?

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

        dp[i][j] = distance between light[i] and point x[j] +
        min of
        min(dp[i-1][k]+x[j]-x[k], where x[k]<x[j]) or
        min(dp[i-1][k]+x[k]-x[j], where x[j]<x[k])

        Let's calculate first part, second part is quite similar.
        We need to find, min {dp[i-1][k] — x[k]} + x[j] and where x[k] < x[j].
        So we just keep minimum value of dp[i-1][k] — x[k] we found so far.

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

      Why did you consider only those 2*n+1 points? Is it never beneficial to move to any other point?

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

        Let say that we have two lights (5..7), (9..10). And you are at point 0.
        So if you move to point 5, you will have free cost for light, but distances is increased by 5. But if you don't move then cost for light will increase by 5, but distance won't. So you could use option 1.

        Something like that. :)

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

How to solve G?

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

    Hint: minimizing distance is very close to minimizing the number of vertrice passed, as 10 >= maxlen = 9

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

    Let's make BFS from node 0. d[v] — distance from 0 to v. For simplicity initially let's suppose there is no leading 0 in answer. In this case, we are sure that answer has length d[n — 1]. For each distance starting from d[n — 1] to 0 we will find set of optimal nodes. d[n — 1] it is only node n — 1. For next distance we will take the nodes which are reachable by the most cheapest edge (greedily).

    To work with leading 0's we just make another bfs from n-1 by only 0 edges and start previous algorithm on some set of nodes which are reachable from n-1 by 0 edges and has smallest distance from node 0.

    Complexity O(n + m).

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

В русских условиях задачи G неправильное описание вывода:

Во второй строке дожны быть записаны номера городов по дороге из Пивграда в Пивбург, занимающей наименьшее время.

The second line of the output should contain the number of cities on the path from Beergrade to Beerburg that takes minimal time.

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

    вы правы. проглядел я это. извиняемся

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

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

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

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

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

Автокомментарий: текст был обновлен пользователем ibra (предыдущая версия, новая версия, сравнить).

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

http://codeforces.com/contest/575/submission/12868120 Турист скопипастил венгерский алгоритм с e-maxx-a. Вот уж от кого не ожидал.. даже названия переменных такие же, а уж про пробелы в фориках я молчу.. Больше не мой кумир

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

    Разве это запрещено правилами контеста?

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

      Я тем же вопросом задавался, но командой решили, что раз на онсайте нельзя было, то и мы не стали.

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

    Может просто e-maxx скопипастил код tourist =)

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

Waiting for the editorial....

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

I always check oeis for problem with one input :)

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

Anyone solved "B. Bribes" using Heavy Light Decomposition(HLD) ?

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

Is there something special about test 5 in problem G?

EDIT: This is a tricky test.

7 7
0 1 1
1 2 0
2 3 0
3 4 0
4 6 1
1 5 2
5 4 0
»
9 лет назад, # |
  Проголосовать: нравится +17 Проголосовать: не нравится

A just Matrix multiplication with corner cases, isn't it?

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

    Yes It's the worst problem I've ever seen. I wrote 6 kilos and still searching the bugs...I also made a segment tree to help

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

      Me really too lazy to write segment tree but my TLE5 says I have to write it.
      Or Partitial multiplications.

      P.S. Yeeeeaaahhhhh, finally got AC!

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

Возможно, кому-то покажется странным мой вопрос. Но, как нужно решать задачу D? Мне кажется, там нет решения. Т.к. в какие бы 2 клеточки мы не походили, вор всегда сможет ускользнуть от нас. И почему проходит решение пройти по две клеточки (вертикально) сначала вправо, а затем влево? Вор может же пойти в те клетки, где мы были в предыдущий момент времени.

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

    Скорее всего, что я неправильно понял условие, поэтому решил спросить.

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

      Мне тоже сначала показалось, что impossible. Однако внимательное прочтение условия показывают, что вор не может идти строго вверх или вниз и тут начинается стратегия:)

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

    Вор обязан сдвинуться с текущей вертикали, так что достаточно сделать 2 прохода по горизонталям. Пусть вор вначале был в четной вертикали, тогда мы его всегда поймаем при втором проходе, иначе — при первом

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

    вор в каждый момент времени находится либо на четной либо на нечетное клетке, с каждым ходом эта четность чередуется.

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

    Я сначала тоже подумал, что решения нет, но потом заметил, что вверх/вниз ходить нельзя.

    Есть точно такая задача на Тимусе: Задача

    Простое решение: 2000 ходов от 1 до 1000 и от 1000 до 1.

    Доказать это решение можно вот как: при первом проходе от 1 до 1000 мы исключаем возможность начального положения преступника в нечетных клетках. Допустим после этого вор стоит в 999 клетке, а мы в 1000, тогда сделав повторный ход в 1000 мы изменим четность вора: он уйдёт в 998 клетку. И после этого вор никогда не сможет подойти к нам впритык, чтобы перепрыгнуть.

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

    Очень известная и старая задача про мышку. например вот. Честно говоря, непонятно, как такие широко известные задачи попадают на контесты такого уровня.

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

      Возможно, эту задачу кто-то второй раз придумал?

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

        Конечно все возможно, но я её много раз много где видел.

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

          Напиши, пожалуйста, ссылки на подобные задачи. Я бы хотел закрепить ассоциацию в памяти :) Мне эта задача далась довольно тяжело...

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

            Тут всего одна задача, меняется только N и предыстория. Я слышал её в варианте как с кошкой (упомянул vitux) и в варианте с поездом, по которому стреляют: слышал лет 5-7 назад в интернете "логическая задача: ...."

            Авторы проявили очень много креативности, когда предложили две строки (но суть и решение не изменилось).

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

    Я прошелся по клеткам от (1,1) и (1,2) до (1000,1) и (1000,2), чтобы 100% поймать вора, так как проверка (х,1) и (х,2) делается с гарантией, что в столбцах до х вора нет, он идет направо. Но почему-то неправильный ответ. Тогда еще прошелся в обратном направлении от 1000 до 1 и он ловится. Сейчас я понял, почему он не ловился в первом проходе и ловился во втором. Я сделал случайно два раза проверку (1000,1) и (1000,2), и вор попадается из-за четности-нечетности :)

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

Новая эра олимп. проги: SSE

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

How to solve C?

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

    Let's say you know that the first N/2 people should go clubbing on Friday and the rest on Saturday. This becomes a simple case of the assignment problem which can be solved in O(N^3) using the Hungarian algorithm. Since there can be N Choose N/2 different combinations of which N/2 people should go clubbing on Friday, just check all possible combinations and run weighted bipartite matching and take the maximum. Complexity is N Choose N/2 * N^3 = 10^9 when N = 20, which passes with some optimizations.

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

      If that is intended solution problem is very bad. It's even more than 10^9 (1.5 * 10^9). I tried that solution and when it timed out I gave up because I thought there must be smarter solution in which I dont have to optimize execution time.

      In the end I just optimized memory consumption of simple DP approach. It needs 2^20 ints which is 4 megabytes and it's too much. Because maximum sum possible is up to 2e7 we can use 26 bit ints instead and spend around 3.5 megabytes. I got accepted but I like it even less than hungarian algorithm solution.

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

        I agree. If this is the intended solution, the time limit should have been at least 3 seconds. Nevertheless, I enjoyed solving the problem for some reason.

        Your solution is nice, but if this is the author's solution, I have nothing else to say ;)

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

        Huh, in high school I somehow got hardcoded in my mind that we always have to leave at least ~4MB safety buffer, because it can disappear from some mysterious reason like included libraries, whatever, I haven't ever really delved into that. I even experienced that I tried to upsolve one problem with ML 32MB and I used 28MB and I was getting MLE and couldn't get rid of it. So in this problem I was afraid of allocating more than 1MB and now you say that you used 3,5MB and got AC.

        Do you know something more on this subject? Maybe because of some reason 0,5MB buffer here was sufficient or maybe CF computes usage of memory based on memory used directly by us and exclude that used indirectly through some libraries etc.?

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

          I don't know anything exact. I guess it depends on libraries included, compiler used and environment in which program is ran. Also it's not easy to measure it so we get all kinds of overheads on different judges. For example on SPOJ for C++ programs it's usually around 2.5MB and here on CF (I used custom invocation for this during the round) it's few KB. But yeah, what you said sounds right, it seems like CF manualy excludes some memory not allocated directly by us.

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

      This solution can be optimized if you notice that the Hungarian algorithm allows rows to be added one by one, in O(n2) each. The complexity becomes if the combinations are generated using recursion.

      edit: actually this may be a wrong bound if the number of valid prefixes at each recursion depth doesn't behave exponentially, but at least it is not worse than O(2n·n2).

      edit: now I've realized the connection of this problem with problem H, which is pretty funny :) According to OEIS the total number of valid prefixes is , so the bound is correct.

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

        Indeed, I observed that but tried with the simpler approach at first which got accepted in 1.95 s. It can be precisely N Choose N/2 * N^2 if you can allocate the same amount of memory.

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

          Why do you need to allocate that much memory? My solution requires time and O(n2) memory.

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

            My bad, I thought of generating all valid subsets iteratively. If implemented recursively as in your solution, it becomes O(N^2) in memory. Sorry I just realized that now since I didn't think much about it after getting accepted in N^3.

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

        btw this is exactly the author's (mine) solution =)

        And yes, problem H was born out of this problem =)

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

Someone please explain solution of D. I saw some accepted solutions, and I don't get it. Sorry, if this is a very easy question, but I just don't get it .

edit : How can we catch the thief in two line-sweeps?

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

    If currently the thief is at an odd position, next hour he will be at an even position. First assume the thief is at odd position. If we check position 2, that means the thief could only be at even position >= 4. So next hour we check position 3, thief cannot choose to go left because we'll be checking that, he is forced to go to 5. Continuing that we check until position 999. After checking position 999 we check 999 again. This forces the thief to fall onto us.

    That's half of the story. If the thief was at odd position initially, we would have caught it. But what if the thief is at even position initially?

    Notice that after (999 — 2 + 1) + 1 hours, the initially even position thief would now be at odd position. Therefore we can simply repeat the above process again.

    That makes the total number of hours required 999 * 2 = 1998.

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

      Did you ever solve a similar problem before or you came up with the idea when you just saw this problem?

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

      x-police,o-thief,#-unoccupied. I am thinking about this:

      at time t=tn

      ....x#.......

      ....xo.......

      at time t=tn+1

      ....#x.......

      ....ox.......

      assuming police uses helicopter to reach the cities, the thief easily gets away, doesn't he?

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

        Police won't catch him in this case.

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

          microtony Thanks a lot for clearing that up. The poblem says...

          "Output is given in chronological order (i-th line contains districts investigated during i-th hour) and should guarantee that the thief is caught in no more than 2015 hours, regardless of thief’s initial position and movement."

          So, what did the problem actually mean? I am totally confused now.

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

            I think you don't understand the problem? It is a output-pnly task. The sample output only illustrates the format and is a "Wrong answer".

            The problem asks you to output a strategy that catches the thief all the time, not something that doesn't work or works some of the time.

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

    Draw pictures for e.g. a 4x2 board instead of 1000x2, it's pretty clear from that. (# is a cell we just blocked, , a cell where the thief can't be, o a cell where he can be)

    oooo     #ooo     o#oo     ,o#o     #,o,     ,#,o     ,,#,     ,,,,
    oooo ... #ooo ... o#oo ... ,o#o ... #,o, ... ,#,o ... ,,#, ... ,,,,
    

    Thanks to the first pass, the thief is forced to be in even/odd columns alternately on even/odd seconds.

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

      I did. I either don't understand the question, or I don't understand the solution.

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

        Is it the answer to my question?

        My question was designated to @microtony and to @Xellos :)

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

          No, I meant I already tried a smaller board, and I didn't get the solution.

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

            My solution failed 12866559
            I tried to solve this by deploying police in similar way one above each other but keeping them for 2 hours and then moving forward from one end to another so that thief if try to cross he will be caught. Since he has no move as (x,y-1) or (x,y+1) he cannot alternate at same x this will force thief to one end and he will be caught.
            How he escaped from (1,1) i am not able to undestand.as i am coming from 1000 column he can move only in city.
            Someone please explain my approach is wrong or i understood the problem totally wrong

            UPD-Understood the cause of failure.

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

Problem D actually appeared in a contest 5 years ago on Timus.

Also writing the checker for this problem is more interesting, when constraints are 10^5. This problem also appeared in mentioned contest. There was randomized DP that passed during that contest (but more tests were added later). Though there is a very beautiful deterministic solution :)

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

    Well... I noticed that this problem was similar to one on Timus when it was too late to change anything. I've actually solved both these problems long time ago, though it seems I have not-so-beautiful solution with bitmasks for the second one.

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

    Bitmasks was the first thing I thought of as well for the second one :D.

    Coincidentally, I solved a slightly similar problem to this D with an arbitrary tree and one person yesterday.

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

      Uhm, what is this bitmask solution you guys are talking about?

      My solution for 2nd problem was going backward & maintain possible positions of the thief (separatedly for odd & even positions)

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

        I guess it must be pretty similar solution. Let's have an array of bits pos[N]. pos[i] equals one iff a thief can be at position [i]. After an attempt to find him at v we set pos[v]=false. and pos on next step equals to (pos<<1 or pos>>1). He will get away if there is at least one non-zero bit after all steps. The complexity is N^2/64.

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

        Subproblem that we want to solve in something like O(N / something): there are some allowed moves (small, at most +-1 in each coordinate), a set of possible positions of the thief and we want to know that set after the thief moves.

        We'll split the array into chunks of size... let's say 20. For each of them and each subset of possible positions of the thief, we can calculate what new subset this would turn into if we only considered possible positions of the thief in it (basically the solution for our subproblem for N = 20); of course, there are still 2 positions outside it that can influence the subset it'd turn into, but checking them is fast — just O(20) and not O(N / 20).

        Then, we can find the new subset of positions where the thief can be for N = 105 in N / 20 variable assignments (=) and O(20) more complex actions. Together with the O(20·220) precomputation above, it's an O(M(N / 20 + 20) + 2·220) algorithm for the whole problem, and the part with O(MN / 20) is exactly MN / 20 assignments, so it should be fast.

        If we had 2 rows, we'd need half as wide chunks (width 10, but still 220 subsets), so it'd be slower, but that problem has one row. I'm pretty sure there wouldn't be any trouble even with a slower judging system.

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

"Post with editorial, results and T-shirts will be posted a bit later"

what does "a bit" mean??

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

Why does this work? 12873839

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

    Во-первых,можно заметить, что уходить в другую сторону от отрезка где будет гореть лампочки бессмысленно. Мы либо можем остаться на своем месте, либо приблизиться к отрезку где горят лампочки. Допустим, что мы можем уменьшить штраф, если пойдем в другую сторону. Понятно, что в текущем ходе, мы только увеличим штраф, если пойдем в другую сторону, а если это необходимо для будущего хода, то тогда мы можем просто стоять на месте, и когда наступить момент, что мы можем уменьшить штраф, то мы его уменьшаем. Во-вторых, если например, мы стоим левее от отрезка где горят лампочки, то нам уходить правее чем li, тоже ничего хорошего не даст. Допустим, что нам нужно идти правее от li для уменьшение штрафа в будущем, тогда мы можем просто стоять на место до наступление момента, когда мы сможем уменьшить штраф. Аналогично, если мы стоим правее. Теперь, можно хранить отрезок (ll, rr), чтобы в этом отрезке штраф для всех точек были равны и принимало минимальное значение штрафа после i-го хода.В таком случае, мы никак не ухудшаем ответ.

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

      Is there O(n) solution for this problem? I made O(n) and have WA on test 5. What special is in this test?