By BledDest, 6 months ago, translation, In English,

Hello Codeforces!

On May 15, 18:05 MSK will be held Educational Codeforces Round 21.

Series of Educational Rounds continue being held as Harbour.Space university initiative! You can read the details about the cooperation between Harbour.Space and Codeforces in the blog post.

The round will be unrated for all users and will be held on extented ACM ICPC rules. After the end of the contest you will have one day to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 7 problems and 2 hours 30 minutes to solve them. We hope that everyone will find something interesting in this contest.

The round was prepared by Mikhail PikMike Piklyaev, Mikhail MikeMirzayanov Mirzayanov and me.

Here is message from Igor Maksimov, Harbour.Space University.

I want to make an announcement of the upcoming 2nd Hello Barcelona ACM-ICPC Bootcamp that will take place in Barcelona from the 27th of September until the 4th of October 2017, in collaboration with Moscow Workshops ACM ICPC, is an opportunity for teams of different levels to prepare for successful participation in ACM ICPC.

The Bootcamp will be split in two divisions:

  • Division A. Designed to prepare students to excel and win medals in the next ACM-ICPC World Finals.
  • Division B. Division B. Designed to help teams prepare for the next season of ACM ICPC Regionals and international competitions. This is an appropriate introduction for teams and students new to the world of ACM ICPC and competitive programming competitions in general. The Division B curriculum features thematic lectures and contests.

Harbour.space University introduce the video about the 1st ACM-ICPC Programming Bootcamp held in February, 2017.

Take a part of the upcoming 2nd Hello Barcelona ACM-ICPC Bootcamp that will take place in Barcelona from the 27th of September until the 5th of October 2017.

More information →

Good luck to everyone!

UPD: Editorial is out.

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

»
6 months ago, # |
  Vote: I like it -22 Vote: I do not like it

is it rated?

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

Problem E is something interesting...

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

    Maybe just servers are too busy or simply too slow... Of course I am kidding!

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

    You are downvoting me badly implying the task is actually EASY. But see, even DIV1 coder did not solved it by his/her own, but just COPYPASTED solution http://codeforces.com/contest/808/submission/27140269

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

      Honestly I am surprised more people didn't do this. It was linked to in the first result I found for "knapsack with small weights", link.

      But also the code is super sketchy, it didn't work until I added a bunch of dummy elements so that there were always 200,000 elements.

      So I guess most D1 coders are too smart to try this :)

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

        It seems that there are infinitely many knapsack problem variations...

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

C problem, I'ts either I'm not understanding the problem or I'm making an erroneous assumption in my thinking that is making me get WA. I'm happy to learn about my mistake once the contest is over.

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

    You can just overflow cup with maximum volume.

    Test:
    3 12
    4 4 4

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

      Thank you. That was the last piece... ahh I can't believe I missed that last part :)

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

How to solve E ?

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

    Lets pick K souvenirs with W=3, so we can take souvenirs with sumW <= m — k * 3 (if negative, skip this K). Lets store souvenirs with w=1,2 in one array sorted by decreasing value c / w. So, if we should choose some souvenirs from this array with sumW = x, we greedily takes souvenirs until sumW <= x (after that sumW == x or x — sumW == 1 — in this case we should take largest souvenir with w=1 or remove smallest souvenir with cost w=1 and take with w=2). So, if we iterates over K in decreasing order, we can maintain second value by two pointers technique.

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

Where is option to hack a solution.

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

how to solve D??

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

    Not sure if my solution is the best, but it worked: So left part is 0, right is whole sum. Go through the array subtracting from right and adding to left. Add current element to set. Check if left is equal to right — solution is YES. When left is greater than right, check if difference between them is even. If yes, check if difference / 2 is in the set. If yes — we have the solution. (I also made the same thing moving right to left, but I guess it may be unnecessary)

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

    Lets store two multisets(left, right). sum(set) — sum of the all elements in set. Lets add [1, 1] to the left and [2, n] to the right. On the next step there a 2 main cases:
    1. sum(left) = sum(right) -> YES
    2. sum(left) > sum(right) (if opposite swap the sets). if left set containse value (sum(left) — sum(right)) / 2 -> YES

    After this step we remove a[i + 1] from right set and add it to left set.

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

    First of all, maintain for each element y the first and last appearance in the array. Now fix the position i where array will be split.

    If sum(1, i) = sum(i + 1, n), we are done.

    Else, if sum(1, i) > sum(i + 1, n) we need to remove a element x from (1, i) and add it to (i + 1, n). We will have that sum(1, i) — x = sum(i + 1, n) + x <=> sum(1, i) — sum(i + 1, n) = 2 * x, x = (sum(1, i) — sum(i + 1, n)) / 2. Also x must be integer, so sum(1, i) — sum(i + 1, n) must be divisible by 2. To check if x appears in (1, i), just check if first appearance of x is <= i.

    If sum(i + 1, n) > sum(1, i) we use same idea, but now x = (sum(i + 1, n) — sum(1, i)) / 2 must appear in (i + 1, n).

    Also check that after moving an element, both parts will be non-empty.

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

I have never hacked solutions. Tell me please, where to start?

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

    On top of the window with accepted solution source code there is link "hack it!".

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

      I found it) The question is "In what ways I can find weak spots of solutions?"

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

        Hacking is code analysing. You can find weaknesses in usage of data structures, e.g. see thread http://codeforces.com/blog/entry/51989?#comment-360480 kunparekh18 at first for problem D used (just like me) set instead of multiset. I managed to hack mine and his (second) solution with input 6 19 6 5 13 6 13 He uses multiset in his second solution, but it was hacked, because of wrong .erase() function usage (see my comment above). There are known hacks on certain algorithms, e.g. I got hacked http://codeforces.com/contest/792/submission/25847128 because of quicksort. You can probably find generator that generates an array corresponding to the worst case for quicksort (I got TLE on such array). During that contest there were participants intentionally looking for quicksort in solutions and hacking them. You can also observe some rare cases that solution doesn't cover (solution weaknesses). To do that you have to clearly undestand the problem and the code of analysed solution. So hacking skills come with experience.

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

Problem D

t.case 6 5 5 4 4 3 3

Here My output is NO I tried to hack my code, it shows unsuccessful. Also another codes output is YES, I tried and also Unsuccessful! what is this?!

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

In problem A,Can someone suggest why this is wrong. Its giving correct answer on my system but wrong on codeforces custom invocation. Code HERE

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

How to solve B?

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

what is the solution of E?

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

Editorial is published.

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

any suggestions how this solutions for D was hacked?
http://codeforces.com/contest/808/submission/27138172

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

Did anybody else notice that problem E was exactly this problem?

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

    Read statements + constraints again carefully. Also if you look at the editorials, you will see they are very different.

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

    It was more like this one

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

How was this hacked for 808D - Разделение массива ? Is there some test case I missed? Please help. 27143749

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

    you need to use a map or multiset

    because when you insert some element in a set 5 times for example and then erasing it once

    you are erasing it completely , not decreasing it's frequency

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

      Thanks a lot... I totally missed this!

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

        Function erase(val) of multiset erases all the entries of the element val. To delete an elemnt you have to specify its position, i.e. use iterator.

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

I am facing a problem ... http://codeforces.com/contest/808/submission/27151049 -- C++ 11 http://codeforces.com/contest/808/submission/27151003 -- C++ 14 Same code, gives WA on case 3 and case 2 respectively, but on my PC, both cases give correct answer.

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

Hacking STL Hash set/map is ridiculous: even if this time unordered_set/multiset/map receives TLE (because of collision), next time in a normal CF round I'll continue using unordered_map/set. It's ~4-5 times faster than ordinary map/set (in normal cases — test data is generated before I submit my program.)

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

    I haven't read the problems but surely most of the time, whether or not you use unordered_set/map is largely orthogonal to the main point of solving the actual problem. So if you choose to use a data structure which is known to have a bad worst case, you really have no one to blame but yourself (and yes, even normal CF rounds have anti-hashing cases).

    But if for some reason you need the extra speed, you can just generate a random number and xor your usages of the unordered_set/map with it to prevent it from breaking on specific known cases.

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

My O(N) solution for the problem B failed with TLE... Apparently reading from 'cin' into a double variable is slow enough to make it potentially fail even on 2*10^5 reads.

Reading from 'cin' into an integer took 124ms: 27174013

Reading from 'cin' into a double took 842ms: 27174024

Also my solution 27126612 failed on system tests with TLE. Exactly the same code 27174040 got accepted later in the practice mode.

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

Why there is no Contest materials box in Educational Round 21 page? (http://codeforces.com/contest/808)

UPD : fixed

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

I want to hide myself so that no one can see me in online.

is there any system to do this??????? How??????