Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

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

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

Всем привет!

В субботу 20 мая в 21:05 MSK состоится рейтинговый Codeforces Round #415.

Как и наш предыдущий 384-й раунд, задачи готовили Кирилл kefaa Гулин и Юра hloya_ygrt Шиляев, но на этот раз к нам присоединился еще и Даниил Melnik Мельниченко. Большое спасибо координатору Леше netman Вистяжу за помощь в подготовке раунда, а также Михаилу MikeMirzayanov Мирзаянову за системы Codeforces и Polygon.

В ожидании второй половины сезона сериала "SKAM", предлагаем вам порешать задачи, главными героями которых будут красавица Нура и уже знакомый вам из 794F - Леха и система безопасности хакер Леха!

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

Надеемся, раунд вам понравится! Всем удачи и высокого рейтинга.

UPD: Обратите внимание, что раунд был перенесен.

UPD2: Разбалловка в каждом дивизионе стандартная: 500 — 1000 — 1500 — 2000 — 2500

UPD3: Мы сильно извиняемся за проблему, произошедшую с задачей С, но так как она повлияла на небольшое количество участников, раунд остается рейтинговым. В то же время, мы можем удалить ваши лишние посылки до системного тестирования и если вас сильно затронула эта проблема, можем сделать раунд нерейтинговым для вас. Пожалуйста, пишите KAN по этому вопросу.

UPD4: Поздравляем победителей! Разбор будет опубликован завтра.

Div1:

  1. Radewoosh

  2. JoeyWheeler

  3. mnbvmar

  4. ershov.stanislav

  5. V--o_o--V

  6. Um_nik

  7. Arterm

Div2:

  1. polygonia

  2. IHaveInt

  3. sup_bro

  4. Cypi

  5. altruist

  6. Anachor

  7. shadowatyy

UPD5: Разбор доступен по ссылке http://codeforces.com/blog/entry/52099

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

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

Удачи авторам с их первым Div.1!

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

А что с пересечением с TCO 2A?

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

    Мы решаем этот вопрос. Возможно раунд будет перенесен.

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

What about the reschedule? http://codeforces.com/blog/entry/52009

edit: nvm

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

Why isn't this on the front page ???

UPD: nvm fixed

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

Very very unusual start time !!! Too bad :(

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

А что с пересечением с Россия-Канада? :)

UPD А, в 16-15 начинается, значит можно ничего не пропускать)

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

Duration will be in the middle of night in east Asia, Will u stay up and burn the candle at both ends?

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

The start time is 2 am. it's so late. participating anyway...

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

...

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

Hope the contest will enjoyable, and spending night time for the contest will successful. :)

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

А в Питере всё равно белые ночи))))

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

    в Архангельске смеются над тем, какие у вас "белые" ночи

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

participants were few in these last contests. in the usual cf time, there had been like an average 6K participants.

btw there are some people who cheat in the contests. Like the guy who hacked 40 times in the last contest (hacked the same person). there should be consequences for people like them.

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

Отчисление отчислением, а контест по расписанию

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

MikeMirzayanov IF CF is down for today and round is gping to be unrated.Plz make Update before such things happen.

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

CF server looks ok now =D

Hopefully, it'll stay like this throughout the contest. And it would be really awesome if they can show the standings and the ratings change really quickly. It's already late in my region. :(

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

I was wondering why the site wouldn't allow me to register for like 5 minutes and then I realized I was currently in div2 lol :D :D

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

Another contest from Belarus :) Hope not be same as tourist's contest, that was veryyyyyy bad

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

15 minutes left. When is the scoring announced?

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

I dream there will be a day when my rating skyrocket to the moon just like bitcoin price :)

P.S. Bitcoin just became candidate master at 1980.

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

Does the rating predictor extension not work anymore?

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

Если все активно ломают задачу, а ты не можешь понять, на чем, то у меня для тебя плохие новости...

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

какой 3 тест в задаче C ?

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

    5
    1 2 3 4 5

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

      какой ответ должен быть ?

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

        72

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

          через дп решали ?

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

            Не уверен, что слова "динамическое программирование" употребимы всякий раз, когда мы переиспользуем предыдущий результат =)

            Скажем, я хочу посчитать степень двойки. Будет ли это дп?

            int p = 1;
            for (int i = 1; <= n; i++)
                p *= 2;
            
  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Возможно, большие числа близкие к 109.

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

      а ваще как надо остаток брать? в каком место просто я все время брал с остатком

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

        Может быть проблема при вычитании. Я только могу гадать, так как не видел твой код =)

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

Russian Code Cup #2.... :'''))))))) (Not 100% sure it will pass though)

EDIT: It passed.

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

How to solve Div2-B?

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

    let add[i] be how much we can add if make a sale in day i. add[i] = max(0, min(l[i] — k[i], k[i])). Then to sell as many items as possible we just sort add and take f biggest values

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

    find out the added profit for each element if k is doubled using profit = final — initial where intial = min(k,l) and final = min(2*k,l). now sort these profits and take the f maximum values since you want your answer to maximum. code :- http://ideone.com/yDxz6l

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

    A[i] : Number of Products that can be sold if not sell out day. B[i] : Number of Products that can be sold if its a sell out day.

    C[i] : B[i]-A[i]. Sort C. Final answer will be Sum(Array A) + F Highest values from C.

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

    After sorting array for (Math.min(2*k,l))-(Math.min(k,l)), we take first F elements with sell-off, next without it.

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

      what if we keep a vector having min(2*k,l),min(k,l) as pair and sort this vector.For first f values we can add first to the answer and for the rest second? what goes wrong with this approach ?got wa in tc 15.

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

        You should sort pair by value of difference beetween min(2*k,l) and min(k,l). My Java code of sorting:

        Long.compare(o2.getKey()-o2.getValue(),o1.getKey()-o1.getValue());
        
»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

How to solve Div2 C?

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

Someone tell a clean approach for Div1B? It was easy to find position of one of the ball. But i couldn't get for finding other...

Also, i expect lots of system failures (including mine)

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

What Was pretest 11 div 1 B

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

    I have wrong answer at it also. I found this test make my code fail 9 3 (2,4,8); I corrected my code and I waiting now to resubmit it. I don't know if it is the test or not.

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

Are you insane? This round should be definitely unrated. At least for div.1

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

    i performed badly hope so your words come true but whats the reason ??

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

    ROUND SHOULD BE UNRATED FOR ALL. MikeMirzayanov

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

      Why is that?

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

      First tell me why are you using fake account

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

      The only reason to make the round unrated would be the need to rejudge Div1-C/Div2-E but, now, it has been announced that they can make it personally unrated for you if you have been affected by this issue. So, yeah... I can't see why this round shouldn't be rated.

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

    We can make it unrated for participants that were affected, if they ask to.

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

    Just out of curiosity.Are u gonna make ur round unrated??

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

      Well, if I had +X rating it will be not fair. Since I got -6 it is OK.

      If authors say that spending 17 minutes trying to find a bug in AC code is OK then it is probably OK.

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

        Yeah in ur case U might have got AC on 2nd question if u had that 17 minutes time.

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

IMO the difficulty is: A <<<< D <<<<<<<<<<<<<<<<<<<<< B,C << E

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

    B was easy only once U get the idea of binary search

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

      How could you do binary search? I thought bsearch as soon as I saw the constraint 60, but I couldn't make any ideas about it.

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

        We can binary search as if there was only one ball, and find a position x where we know that there is a ball.

        Then we can repeat the same procedure, but this time instead of searching over the region [1, n] we search [1, x - 1] and [x + 1, n].

        Edit: They are dishes not balls, but same idea :D

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

          Could you tell me how to "binary search as if there was only one dish to find a position x"?

          EDIT: They are dished not balls xD

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

            At every iteration in our binary search, we query 1 mid mid+1. Based on the answer, we know whether we need to look to the left or to the right for the closest dish, and set lo = mid+1 or hi = mid accordingly.

            Although this does not find the leftmost dish, it is guaranteed that this will give the location of one of the dishes. To see why, notice that there will always be at least one dish in the starting interval [1, n]. At each iteration of the binary search, the closest dish might change, but there will always be a valid dish in either [lo, mid] or [mid + 1, hi]. If we receive TAK for our query, then we know that there is a dish in the left interval, because if there wasn't, then there must be a dish in the right interval, and the query would have given NIE. The same logic applies for choosing the right interval if we receive NIE. Hope that helps!

            P.S. This approach is correct: 27248627

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

          I did the same as u have said. What is wrong with my code.Gave WA in pretest 11 http://codeforces.com/contest/810/submission/27252700

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

        If you query (x, x+1), there definitely exists a dish at position <= x if ans is TAK and there exists a dish >= x+1 otherwise. Using this, keep querying (mid, mid+1) and find the position of the first dish. After that check if there exists a dish to its right and use the same procedure on some particular interval on its right. Otherwise do it on the left.

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

          Wow..... I thought the idea of querying (x, x+1) but never imagined to do binary search with that. 160 people who solved B must be geniuses!

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

        U can check here.

        I tried to first find one of the dishes by always taking that half which has closest dish(since it is guaranteed to have a dish).

        let it be k.

        Next again do same think for segments (1,k-1) and (k+2,n) and check for cases k-1,k+1,k+2 manually

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

        The first observation you can make is that, if you assign a value to each dish, you will have an array D, where D[i] == 0 iff there is a dish he ordered. In addition if you imagine the graph, you are looking for 2 minimums of the function f(i) = D[i].
        Now you can binary search to find this minimums, if after a query the answer is TAK, it must mean there is a minimum to the left, in the same way, if the answer is NIE there must be a minimum to the right.

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

    Even though idea on D is easy, splay tree was not a common subject for me (and most coders, I guess) TT

    I first googled for some splay tree resources, but soon I gave up and wrote N^1.5 solution

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

      How can we solve D with Splay Tree? I'm not sure what the easy idea is.

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

      Me too. Actually this was the first time that I used the splay tree. I went to http://cubelover.tistory.com/10, copy-and-pasted, modified a little, and debugged and debugged and debugged. Really wanted to give up, but B and C were far harder, so....

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

What is wrong with my div2C solution ? http://codeforces.com/contest/810/submission/27252345

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

    Your mod is 1e9+9 while it should be 1e9+7

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

      It doesn't matter. My previous submissions had 1e9+7 and still didn't pass

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

        maybe sum < 0 ! sum=sum%mod;

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

        sum=sum+(x[i]*(modular(2,i,mod)-modular(2,n-i-1,mod)))%mod;

        should be

        sum=sum+(x[i]*((modular(2,i,mod)-modular(2,n-i-1,mod))+mod)%mod)%mod;

        As (a-b)%m = (a-b+m)%m;

        as a-b can be negative also

        Also mod value should be 1e9+7

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

          Take array 1,2,3. Sum is 6 and it is ok when module is negative.If i change it to be always positive it will output 9 which is not correct

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

            no it gives 6 only.

             sum += 1*(1-4+mod)%mod; -->> (1e9+4)*1
                sum += 2*(2-2+mod)%mod; -->> (1e9+0)*2
                sum += 3*(4-1+mod)%mod; -->> (1e9+10)*3
            

            which comes out to be 6 only when added

            You shoud take mod with 1e9+7 not 1e9+9 as I said earlier. You are repeating the same mistake.

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

              I'm sorry, my bad, but still my solution gives correct answer. :((

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

    I think the negative from

    sum=sum+(x[i]*(modular(2,i,mod)-modular(2,n-i-1,mod)))%mod;
    

    Screws up the modulo.

    CMIIW

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

    (modular(2,i,mod)-modular(2,n-i-1,mod) this line can be negative so should do:
    (((modular(2,i,mod)-modular(2,n-i-1,mod))%mod+mod)%mod

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

      Consider array 1,2,3. it is -3*1+0*2+3*3 = 6 which is correct. So it doesn't matter i guess

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

        nono, I mean given i < j, 2^i%mod can be larger thak 2^j%mod.
        EDIT: imagine if one is 1e9+8, and the other is 1e9+6, the substraction would dive -(1e9+5) instead of whatever value you would need.

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

    modular(2,i,mod)-modular(2,n-i-1,mod)) can be negative also and you cannot perform (negative numer) % mod which leads to wromg answer. you need to add multiple of mod to it to make it positive before applying mod opertion

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

      Look above, tell me if i'm wrong.

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

      I did not take care of negative modulo but passed the pre-tests. Do you reckon my solution will pass sys tests? I mean I'm pretty sure that negative modulo case would have occured in the pre-tests. How did it pass?

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

Div.1 D is quite similar with APIO 2016 Boat, or is it not?

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

    The idea itself is completely different, but i was inspired by APIO task when thinking about my own one.

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

How do you solve Div1 B?

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

    I'm pretty confident of the following solution.

    The amazing trick is to always let a + 1 = b whenever we query. Thus, this gives us the following information: "there is a dish closer to the left" or "there is a dish closer to the right".

    We are able to find the first dish this way. We perform a sort of "binary search" on the range [1, n]. Each time, we will query two consecutive midpoints m and m + 1 (where m = (l + r) / 2 as usual), then if it tells us there is one closer to the left, we go to [l, m], otherwise [m + 1, r]. Once the range has been compressed to 1 or 2 elements only, we will have found one dish.

    The second dish can be found similarly. Let x be the location of the first dish. Then, we will perform two separate binary searches like the one above: [1, x - 1] and [x + 1, n]. The amazing thing here is that the first dish x will never conflict with any dish in those ranges; that is, if a dish in either range exist, our binary search will find that and not x.

    We start with [1, x - 1]. If the answer to the queries is always , and query [x - 1, x] is also , then we will know, that there is no dish in the range [1, x - 1]. Thus we can find the dish in the other range.

    Overall this takes queries which fits comfortably in 60 queries.

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

Missed submitting the Div. 1 C by 1 minute... horrible feeling ever! :(

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

    Hope you will get WA :)

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

    Can you explain how to do it.

    I thought like we can subtract one from all then a[i][j]=i^j.

    Later I thought like f(x1,y1,x2,y2)=f(0,0,x2,y2)+f(0,0,x1,y1)-f(0,0,x1,y2)-f(0,0,x2,y1) something of this sort. But i couldnt compute f function.

    Is this the way to proceed.If not whats ur approach??

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

How to solve div2 C without using double for, which gives TLE for sure? :(

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

Problem C:

I know that I placed a mistake somewhere OVER 9000 formulas. I know the WA test. I could not find in within 20 minutes of debug.

Shit.

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

what is wrong with my Div2 D solution. I used Binary search to first find the 1st dish(let's say k). Then I applied Binary search on 1 to k-1 and k+1 to n to find another solution. http://codeforces.com/contest/810/submission/27252700 The code gives WA on pretest 11.

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

    U should'nt do binary search from k+1 to n.U must do from k+2 to n And check for cases k-1,k+1,k+2 separately(this separate cases bcoz equality gives tak)

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

      If I say that a is first ball, then if second ball is little greater than middle of a+1..N then there is a chance that I get TAK, TAK, ... again since a+1 is closer to a and I miss the correct ball which was in middle and shift my range wrongly?

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

      Could you please clear my question?

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

        Yeah kind of similar thought since (x+y)/2 is always closer to x than y. So your thought process is right. There is chance of missing some point

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

I believe for B div 1 better option was asking for one dish and having score 750 :)

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

есть ли программа которая заранее говорит сколько рейтинга получишь или потеряешь ?

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

Is intended complexity of E O(n * log(n) * 35)?

BTW, I was using Wi-Fi of Rushmore Plaza but in the last 30 minutes it started not working. So I couldn't do anything. Is there anyone having same problem?

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

Am I the only one in the world who doesn't like interactive problems :\

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

    no

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

    They should mention in the blog that there are going to be interactive problems at least. -_-

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

      We wanted to, but as it wasn't noticed in VK cup round 3 announce, we decided not to do that.

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

      Why should they?

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

        Because some people don't know what an interactive problem is.

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

          Do you realize how stupid this actually sounds? Some people will never know what a DP problem is, should this be announced, too? It's been a long time since interactive tasks were introduced by CF, not to mention that the statement makes everything clear.

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

            I don't think that your comparison is valid, you compared an algorithm (dp) to a technical term ( interactive problem, you should know about flushing, which has nothing to do with CP )

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

              I don't see how that matters. Flushing has nothing to do with CP? Not sure how you define "has sth to do with CP" but many things had nothing to do with CP until they were used for first time. And even "you should know about flushing" is wrong since the statement tells you what to do. I will once again say that this type of problems were introduced a long ago and the announcements of the first few rounds which used them had a link to the detailed guide.

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

      I am sorry .But do people prepare any template or anything for interactive problems??

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

        No, they should prepare Aspirin :D

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

        Something like this does the job for me:

        #include <bits/stdc++.h>
        
        using namespace std;
        
        
        
        int main() {
        
        }
        
      • »
        »
        »
        »
        7 лет назад, # ^ |
          Проголосовать: нравится +5 Проголосовать: не нравится

        Nope, I just don't like them so I tend to avoid the contests that have them. And I guess there are a lot like me.

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

It usually sucks when authors put boring stories thinking this will make statements more interesting. But it sucks a damn sight more when their English sucks as much as the stories.

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

can this problem be solved?

shift [l,r] to right

add to [l,r] 1

q,l,r <= 1e5

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

Aren't the value of cells equal to abs(x-y)+1 if((x+y)%2)==0 and equal to x+y-1 otherwise where x and y are the row and column number respectively. I m talking about DIV 1C /DIV2 E

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

Can somebody explain me, why in B there were "TAK" and "NIE" ("YES" and "NO" in Polish)?

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

    It is not fair, you had advantage at the beginning :P

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

    Maybe it's cultural appropriation :)

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

    3/3 authors and coordinator are from Belarus and this words are the same in belarussian language. Also we are fans of main.edu.pl site and already get used to such answers to queries. :)

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

Waiting for system testing to start ...

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

problem C (Do you want a date) link : https://code.google.com/codejam/contest/11304486/dashboard I have submitted the same solution.

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

    That contest is old (from 2017) so probably nobody who took part of the contest remembered it...

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

    Sorry about that, but we proposed our contest much earlier than kickstart 2017 happened.

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

      but how this justifies to keep the round rated as more than 50% of DIV1 people soved only 1 problem which is same to an old problem.

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

Waiting for System testing

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

How to solve Div1 C? I only found that dat[i][j] = ((i-1) ^ (j-1)) + 1.

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

    I couldn't solve it yet so don't take this as a solution but probably you have to solve 4 queries that are query(1,1,x2,y2) — query(1,1,x1-1,y2) — query(1,1,x2,y1-1) + query(1,1,x1-1,y1-1) and then solving queries with x1 = y1 = 0 is easier.

    Then you can see that there are some squares (of sizes powers of two) that can be calculated easily, but I don't know what happens when the area is too big in one dimension but not in the other one, probably there's something to do with some rectangles that I couldn't calculate but I don't know.

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

      You can calc answer for query(0, 0, x, y, k) with dp (code will desribe it better than words): 27247417

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

    We will solve the problem for queries with x1 = y1 = 0, it's obvious how to solve the actual problem afterwards.

    Notice that you can create the grid by starting with a 1x1 cell with a 1 in it. Then, to go from size 2k to size 2k + 1 you take four copies of a 2k grid in a square and add 2k to all values in the two 2k cells on the antidiagonal (you may want to print the grid for small values to visualize this).

    We can use this generation process in reverse: initially the query is contained in a square of some size 2k. We can split it into four subqueries on grids of size 2k - 1. Specifically, if we are querying for ((x, y), M) (where M is the upperbound) on a grid of size 2k, then this is identical to adding together the following four subqueries:

    • ((x, y), M) on a grid of size 2k - 1
    • ((x - 2k - 1, y), M - 2k - 1) on a grid of size 2k - 1
    • ((x, y - 2k - 1), M - 2k - 1) on a grid of size 2k - 1
    • ((x - 2k - 1, y - 2k - 1), M) on a grid of size 2k - 1

    This recursion is quite expensive, but it turns out that in a lot of cases we can directly compute the answer. We can also see that the square of size 2k contains all numbers from 1 to 2k, each 2k times each. So if x, y ≥ 2k, i.e. we query the entire square, we can simply add 2k times each of 1..min(2k, M) to the answer. For the case when only one of x, y is larger than 2k you'll have to think a little harder, but that too has a closed form solution.

    Finally, note that when coming out of the recursion for subqueries on the antidiagonal (where you subtract 2k from M), you actually have to add 2k to the answer for each number that you added 'down there'. So not only should you return the sum of the query from your recursive function, but also the amount of numbers in the sum.

    EDIT: Here is my accepted solution. It contains some idiosyncracies, I'll post a more compact solution once upsolving is possible.

    EDIT2: Simpler solution.

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

Rating of most of the DIV1 users will change on basis of one question today which u can find by googling moreover it was a recent problem so many of the DIV1 users must had participated in that contest too which gives them a super edge over others. This is just not right for CF :(

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

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

please start system test.

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

I was cheated by the "int".....Though it was hacked for some other reasons. someone's solution for div2/C

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

What was the hacking case for DIV 2B?

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

So what is test 47 in D1 A?

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

    I feel like it must be something bizarre, because running my solution locally against Lewin's on randomly generated cases there is no difference. If anybody is bored here is my submission, 27240358, I can not for the life of me figure out why it is wrong.

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

      Could it be int overflow? (Edit: scratch that, looks fine)

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

      I see your solution as running on test 1

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

        Yeah it seems it is being rejudged. But it originally showed for me as "Wrong answer on test 47".

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

          Oh now it shows the issue as: "Can't find file C:\Contesters\Work\invoker-prod\work\codeforces2\4375ab888520facceff67c17abfbd1cf\check-e1271c8a6a57f31648a43d4032fc0bbe\run\output.fd0138e687.txt."

          On test 47. WTF.

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

System tests seem to have started and paused...

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

system test is like

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

system test like

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

B div 2, WA 15, почему?

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

    Ты получишь больший результат, если увеличишь на большее число. То есть сортировать надо не по конечному кол-ву единиц реализованного товара, а по тому, насколько это количество увеличится

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

For Div2 D,

First I applied binary search. Stopped the loop when both left and right pointers became equal, that was 1 of the ordered dishes, say k.

Then I applied binary search from 1 to k-1, and k+1 to n. At least 1 of these segments had an ordered dish, so finally queried once for the answers obtained in the above 2 binary searches.

What is wrong with that?

Code

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

Anyone knows why I'm getting WA on test 15 Div2 B?Solution(yes I know my solution is a total overkill...)

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

    I think what is wrong with your solution is the following: you have to check in the for at line 55 if you have already used the products for that index, because sometimes 2 * products_i could be less than products_j for some i,j, let me know if you need a more detailed explanation

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

Will ratings be updated today or we'll have to wait until the problem with the people who wants to be unrated is solved?

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

What is the meaning of N=1 in C. Do you want a date?

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

Формулировка задачи С второго дивизиона превосходна! Очень правдоподобная история. Я улыбался, когда читал.

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

Div 2C/Div 1A. Test 69 doesn't accept java's Arrays.sort. So frustrated...

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

    Arrays.sort uses modified QuickSort (which is O(n^2) in worst-case) for primitive types. So I don't know how hard to create worst case, but test#69 obviously that case.

    On other side, Arrays.sort uses TrimSort (which is O(nlogn) for worst-case) for objects. So all you need to do is change x from array of ints to array of Integers.

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

BANG BANG!

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

Will div2 rating going to update or not?Its too late

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

Hi,

Can you please help me understand why the following solution exceeds the time limit for div 2 problem C: http://codeforces.com/contest/810/submission/27252557 ? It seems like most accepted solutions have the exact same approach.

Thanks

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

So, what happened with moejy0viiiiiv and jcccccccccccccccccccccsb?

Edit: never mind, they probably requested to be excluded due to the issues on problem C.

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

Hi! In div2 C, I did exactly what I am supposed to but it didnt pass. Can anyone help me please. http://codeforces.com/contest/810/submission/27247180 ____I don't understand whats wrong with this.

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

editorial?

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

Excuse me, where is the editorial?

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

Hey friends,

I was trying to solve problem C of this round in C++, but I've just been getting 'wrong answer' on test 6. I get right answers when there are small values to deal with, but when the numbers get bigger, like in test 6, things go wrong. I feel like the algorithm itself is fine, but I'm not handling the data properly. I'm also new to C++, so that's totally possible. I tried a lot to fix the error, but nothing seems to work. Anyone out there to help me out? I would really appreciate it. Here's my code (http://codeforces.com/contest/810/submission/27260339):

include include include

using namespace std;

int main(){ long long mod = 1000000007;

int n; cin >> n;

long long arr[n];

for (int i = 0; i < n; i++){ cin >> arr[i]; }

sort(arr, arr + n);

long long ans = 0;

for (int k = 0; k < n; k++ ){ ans += (long long)((pow(2, k) — 1)*arr[k]) % mod; ans -= (long long)((pow(2, n-k-1) — 1)*arr[k]) % mod;

if(ans < 0){
   ans += mod;
}

} cout << ans%mod << endl; }

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

    This is an overflow issue. You have to typecast the variables inside the brackets, that is, before the multiplication. You are typecasting them after the multiplication.

    A short trick for this to avoid writing long long everywhere is to just multiply 1LL to the expression which might cause an overflow, which makes the execution of that particular expression in 64-bit. 1LL is an inbuilt long long 1.

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

Can anyone say what is wrong with my solution Div 2 B

(http://codeforces.com/contest/810/submission/27260753)

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

    People often get WA16 because sorts Math.min(2*k,l), but it should be sorted by difference between Math.min(2*k,l) and Math.min(k,l). So you need sort increasing of profit.

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

How to solve div1 D better than O(n sqrt n)

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

    I'll write it here too :) You should use a special data structure called treap. You can read about it somewhere on the Internet (I don't know sites on English, which can help you to understand this data structure) or just look at my code.

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

    How to solve it in nsqrtn?

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

      The task can be reduced to some queries on an array:

      delete one element from the array

      add one element

      increase all elemets [l,r] by 1

      shift segment [l,r] to right

      So sqrt-decomposition may help you to process these queries. And if you want to understand, how it can be reduced to such queries, please, wait the editorial. It will be published in a few hours.

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

A great contest for me! +228, Rank 42 :) It is always 42 indeed! :)