hloya_ygrt's blog

By hloya_ygrt, history, 6 weeks ago, translation, In English,

Hello everyone!

This Saturday May 20, 21:05 MSK rated Codeforces Round #415 takes place.

As for our previous round 384, the problems were set by Kiril kefaa Gulin and Yura hloya_ygrt Shilyaev. And this time Daniil Melnik Melnichenko joined us! Many thanks to coordinator Alex netman Vistyazh for help in preparations of the round, and also to Mike MikeMirzayanov Mirzayanov for Codeforces and Polygon systems.

While everyone is waiting for second half of "SKAM" series season, we offer you to solve problems, main characters of which would be stunning girl Noora and well-known to you from 794F - Leha and security system hacker Leha!

As always, participants of both divisions will be given 5 problems and 2 hours to solve them. Scoring will be announced before the round.

We hope you'll like our round! I wish everyone good luck and high rating!

UPD: Please pay attention that round was rescheduled.

UPD2: Scoring in each division is standart 500 — 1000 — 1500 — 2000 — 2500

UPD3: We are extremely sorry about the issue with problem C, but since it affected not many participants, round remains rated. At the same time, we can remove your unnecessary submissions and if you were affected, we can make round unrated for you. Please contact KAN with this question.

UPD4: Congratulations to the winners! Editorial will be posted tomorrow.

Div1:

  1. Radewoosh

  2. izrak

  3. mnbvmar

  4. ershov.stanislav

  5. V--o_o--V

  6. Um_nik

  7. Arterm

Div2:

  1. polygonia

  2. Delsin

  3. utsav.delhi2

  4. Cypi

  5. altruist

  6. Anachor

  7. shadowatyy

UPD5: Editorial is available http://codeforces.com/blog/entry/52099.

 
 
 
 
  • Vote: I like it  
  • +289
  • Vote: I do not like it  

»
6 weeks ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

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

edit: nvm

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

    Round has been rescheduled to another time.

»
6 weeks ago, # |
Rev. 2   Vote: I like it -7 Vote: I do not like it

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

UPD: nvm fixed

»
6 weeks ago, # |
Rev. 2   Vote: I like it +4 Vote: I do not like it

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

»
6 weeks ago, # |
Rev. 2   Vote: I like it +7 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    same here..participating anyways :D

»
6 weeks ago, # |
  Vote: I like it +14 Vote: I do not like it

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

»
6 weeks ago, # |
Rev. 2   Vote: I like it -46 Vote: I do not like it

...

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
6 weeks ago, # |
  Vote: I like it -14 Vote: I do not like it

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.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    that guy was disqualified :)

    (didn't know it till now as he was disqualified after the ratings change). he had a 397 up as far as i remember.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it -9 Vote: I do not like it

    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.

»
6 weeks ago, # |
  Vote: I like it +20 Vote: I do not like it

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

»
6 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

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. :(

»
6 weeks ago, # |
  Vote: I like it +53 Vote: I do not like it

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

»
6 weeks ago, # |
Rev. 3   Vote: I like it -29 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +26 Vote: I do not like it

    Maybe instead of complaining you can practice both English and competitive programming?

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Leaving all my exams, I excitedly registered in the contest to celebrate my second year on Codeforces :)

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

15 minutes left. When is the scoring announced?

»
6 weeks ago, # |
Rev. 5   Vote: I like it +6 Vote: I do not like it

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.

»
6 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

Does the rating predictor extension not work anymore?

»
6 weeks ago, # |
Rev. 2   Vote: I like it +150 Vote: I do not like it

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

EDIT: It passed.

»
6 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

How to solve Div2-B?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    If L <= K, you don't have to choose that day. Suppose L > K Let d = Math.min(L, 2*K) — d sort and choose the first f of such that contribute the maximum and sum the others as usual. This should work to give you what you want.

    • »
      »
      »
      5 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Could you please find mistake in my solution 27246120? Since I have also used same logic as yours. Thank you for reading.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

  • »
    »
    6 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        sorted in descending order.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        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());
        
        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          thanks..my logic was wrong.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve Div2 C?

»
6 weeks ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

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)

  • »
    »
    6 weeks ago, # ^ |
    Rev. 2   Vote: I like it +10 Vote: I do not like it

    Accepted Solution:

    If the position of the first ball is X, then I searched in the same way for the second ball in 1 => X — 1 & X + 1 => n

»
6 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

What Was pretest 11 div 1 B

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
6 weeks ago, # |
  Vote: I like it +71 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it -14 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it -47 Vote: I do not like it

    ROUND SHOULD BE UNRATED FOR ALL. MikeMirzayanov

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it -10 Vote: I do not like it

      Why is that?

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +19 Vote: I do not like it

      First tell me why are you using fake account

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +17 Vote: I do not like it

      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.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

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

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +15 Vote: I do not like it

      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.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

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

»
6 weeks ago, # |
  Vote: I like it +15 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +13 Vote: I do not like it

      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.

      • »
        »
        »
        »
        6 weeks ago, # ^ |
        Rev. 4   Vote: I like it 0 Vote: I do not like it

        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

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
          Rev. 2   Vote: I like it +5 Vote: I do not like it

          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

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
            Rev. 7   Vote: I like it 0 Vote: I do not like it

            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

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it -8 Vote: I do not like it

          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

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it +23 Vote: I do not like it

        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.

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it +24 Vote: I do not like it

          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!

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it -8 Vote: I do not like it

        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.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +25 Vote: I do not like it

    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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +25 Vote: I do not like it

      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....

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +45 Vote: I do not like it

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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it -11 Vote: I do not like it

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

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        maybe sum < 0 ! sum=sum%mod;

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          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

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
            Rev. 3   Vote: I like it 0 Vote: I do not like it

            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.

            • »
              »
              »
              »
              »
              »
              »
              5 weeks ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    (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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

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

      • »
        »
        »
        »
        6 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        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.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Look above, tell me if i'm wrong.

    • »
      »
      »
      6 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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?

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        It must work with negative module. And i don't know why it didn't pass.

»
6 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

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

»
6 weeks ago, # |
  Vote: I like it +15 Vote: I do not like it

How do you solve Div1 B?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +38 Vote: I do not like it

    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.

»
6 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +61 Vote: I do not like it

    Hope you will get WA :)

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Wasted too much time, could not spot this bug n && (1LL << k) instead of n & (1LL << k).

      Such silly mistake cost me like 20 minutes >_<

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        Maybe it will be easier for you when I say that once I had p ! = x, instead p|=x. I spent more than 15 x 15 minutes to see it :)

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +11 Vote: I do not like it

      I am depressed

      crippling depression

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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??

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
6 weeks ago, # |
  Vote: I like it +29 Vote: I do not like it

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.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    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)

    • »
      »
      »
      6 weeks ago, # ^ |
      Rev. 6   Vote: I like it 0 Vote: I do not like it

      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?

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Could you please clear my question?

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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

»
6 weeks ago, # |
  Vote: I like it +21 Vote: I do not like it

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

»
6 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    You can improve that to O(n * log(n) * (2 ^ 5) * 5) (or simply O(n * log2(n) * 5) because sum of x 2 ^ d(x) is n*log(n)) by doing some dp trick

  • »
    »
    6 weeks ago, # ^ |
    Rev. 2   Vote: I like it +5 Vote: I do not like it

    I have an solution.

  • »
    »
    6 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I passed it with . It actually should be less but I could only prove an upper bound.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    Intended solution has complexity .

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Till the editorial is not published, everyone can look through the author's solution 27254027 :)

»
6 weeks ago, # |
  Vote: I like it +33 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    no

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it -11 Vote: I do not like it

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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it -19 Vote: I do not like it

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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it +2 Vote: I do not like it

      Why should they?

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +8 Vote: I do not like it

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

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +5 Vote: I do not like it

          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.

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
            Rev. 2   Vote: I like it +3 Vote: I do not like it

            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 )

            • »
              »
              »
              »
              »
              »
              »
              5 weeks ago, # ^ |
                Vote: I like it +2 Vote: I do not like it

              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.

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it -10 Vote: I do not like it

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

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it +33 Vote: I do not like it

        No, they should prepare Aspirin :D

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it +27 Vote: I do not like it

        Something like this does the job for me:

        #include <bits/stdc++.h>
        
        using namespace std;
        
        
        
        int main() {
        
        }
        
      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        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.

»
6 weeks ago, # |
  Vote: I like it +57 Vote: I do not like it

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.

»
6 weeks ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

can this problem be solved?

shift [l,r] to right

add to [l,r] 1

q,l,r <= 1e5

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Shifting is just erasing element at position r and inserting it before l. I think it can be done with sqrt decomposition.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    Yes, it can be solved with the help of the data structure called treap. Furthermore the complexity will be about logN on one query.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    They are equal to (x — 1) ^ (y — 1) + 1

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      all the diagonal(1,1 to n,n) elements are 1. it does not satisfy.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        Why? For each a, a^a is equal to zero. So, this condition is statisfied.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +4 Vote: I do not like it

          i thought ^ is pow. my bad thanks

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Apart from observation, does there exists any way of proving it?

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +13 Vote: I do not like it

        Yes, It is equivalent to calculating grundy numbers for a two pile nim of sizes (i-1) and (j-1) and adding one to it.(Nim idea comes from fact that we are taking mex of row and column )

»
6 weeks ago, # |
  Vote: I like it +73 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +28 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Maybe it's cultural appropriation :)

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +41 Vote: I do not like it

    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. :)

»
6 weeks ago, # |
  Vote: I like it +43 Vote: I do not like it

Waiting for system testing to start ...

»
6 weeks ago, # |
  Vote: I like it +11 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

»
6 weeks ago, # |
  Vote: I like it +9 Vote: I do not like it

Waiting for System testing

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

  • »
    »
    6 weeks ago, # ^ |
    Rev. 4   Vote: I like it +3 Vote: I do not like it

    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.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thank you! Far better explanation than editorial!

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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 :(

»
6 weeks ago, # |
  Vote: I like it +133 Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it +4 Vote: I do not like it

please start system test.

»
6 weeks ago, # |
Rev. 5   Vote: I like it +10 Vote: I do not like it

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

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

What was the hacking case for DIV 2B?

»
6 weeks ago, # |
  Vote: I like it +10 Vote: I do not like it

So what is test 47 in D1 A?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      6 weeks ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I see your solution as running on test 1

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it +10 Vote: I do not like it

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

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it +23 Vote: I do not like it

          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.

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
              Vote: I like it +16 Vote: I do not like it

            Maybe it is tested on WinXP and the output got encrypted?

»
6 weeks ago, # |
  Vote: I like it +21 Vote: I do not like it

System tests seem to have started and paused...

»
6 weeks ago, # |
  Vote: I like it +33 Vote: I do not like it

system test like

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

»
5 weeks ago, # |
  Vote: I like it +88 Vote: I do not like it

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

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    There is one subset, {x}, maximum distance is |x-x|=0.So, answer is zero.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    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.

»
5 weeks ago, # |
  Vote: I like it +58 Vote: I do not like it

BANG BANG!

»
5 weeks ago, # |
  Vote: I like it +21 Vote: I do not like it

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

»
5 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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

»
5 weeks ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

So, what happened with moejy0viiiiiv and jcccccccccccccccccccccsb?

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

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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.

»
5 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

editorial?

»
5 weeks ago, # |
  Vote: I like it +6 Vote: I do not like it

Excuse me, where is the editorial?

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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; }

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it +5 Vote: I do not like it

    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.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      That doesn't seem to work either:( I implemented the exact same algorithm in python (without all the 'long's and 'int's) and was able to pass test 6. I think it just some data type thing in C++ that I'm not seeing. Can anyone please help me out? Here's my code:

      27270625

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

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

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    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.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    How to solve it in nsqrtn?

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +15 Vote: I do not like it

      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.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi,

I've tried a method for 809A but its not working. Can anyone help me why it isn't not working. It is failing on the 6th test itself.

http://codeforces.com/contest/809/submission/27281025

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

I am getting WA in Kickstart Round B 2017 PROBLEM A.while the similar code gets accepted here for problem C.can you help me please to find out what is wrong? my submission:(https://ideone.com/vdTEOv)