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

Привет, Codeforces!

Отличные новости! Harbour.Space поддержал возвращение образовательных раундов на Codeforces! Подробности можно прочитать в посте.

27 марта в 17:35 MSK начнётся Educational Codeforces Round 18.

Вам будет предложено 6 задач и 2 часа на их решение. Мы надеемся, что все, и новички, и опытные программисты, найдут для себя что-нибудь интересное в этом контесте. Контест будет нерейтинговым.

Раунд вместе со мной готовили Михаил awoo Пикляев и Михаил MikeMirzayanov Мирзаянов. Благодарим Максима HellKitsune Финютина и Алексея ashmelev Шмелёва за тестирование раунда.

Надеемся, контест вам понравится! Желаем удачи!

UPD: Разбор задач.

UPD2: Все успешные взломы добавлены в набор тестов, и все решения перетестированы на новом наборе. Спасибо за участие!

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

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

Can anyone confirm to me that this contest won't be rated, because im not sure

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

Unfortunately, it clashes with csacademy round 22.

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

MikeMirzayanov

** WHY TO ORGANIZE SUCH UNRATED CONTEST? IF ANYONE WANT TO LEARN HE CAN PARTICIPATE VIRTUALLY.AND IF ANYONE WANT TO SOLVE QUESTS LIKE THESE ROUNDS' THEN WE CAN USE TAG OF EDUCATIONAL ON PROBLEMS LIKE PTHER TAGS DS,DP ,GRAPHS ETC.SO,THERE IS NOTHING IN FAVOUR OF THESE KIND OF UNRATED ROUNDS**

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

Making educational round be rated, the number of participant will increase a lot. Sorry for my poor English.

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

Thank you Harbour.Space for Supporting........

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

IS IT RATED!!?!?!?!?!?

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

It's interesting that some of my friends are more interested in participating when it's not rated haha

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

The issue with problem C may have affected some contestants. The round should be unrated.

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

E is so beautiful and amazing! Thank you!

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

Did someone else keep getting WA15 on F? If yes how did he/she fix it?

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

isn't E a binary search? get WA at test4!

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

Will the test data be published now or one day later?

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

Has "unused" hacked his own solution ?! Appears so to me !!

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

Is F relative to Linear Programming? Using duality lead the problem to work with lines.

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

What does "unexpected verdict" mean when hacking a solution? I received it while hacking problem C.

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

I tried to hack C and the verdict was "Unexpected verdict". What does it mean?

**UPD**: It is now a successful hacking attempt
»
9 лет назад, скрыть # |
 
Проголосовать: нравится -7 Проголосовать: не нравится

Why do I get Unexpected Verdict while hacking C?

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

What was the expected complexity of problem E?I guess I had a solution in nsqrt(max(ai)).

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

I hacked a friend on a solution he sent after the contest finished but still got -1 on hacks. Is this intended?

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

Why so many people hacking their own solution?

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

Great contest! Are editorials for the problems going to be published? And when?

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

How to solve D?

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

    notice that all values in left subtree < value at current node and all values in right subtree > current node and all values in this subtree are in some range [l , r] and the value at current node is (l + r) / 2. Using this you can find the node u in log(N) the same way as you find stuff in a binary search tree and then continue the traversal there while mainting the list of ancestors of a node.

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

    I used two variables l and r to mark the leftmost (smallest) number and rightmost (largest) number of the subtree of current node.

    For 'L' and 'R' operations:

    When l = r, it means that the current node is at the deepest layer, so we should ignore these operations. Otherwise, shrink the range by making l = mid+1 for 'R' operations, or r = mid-1 for 'L' operations, where mid = (l+r)/2 (the current node).

    For 'U' operations:

    When l = 1 and r = n, it means that the current node is the root, and we should ignore this operation. Otherwise, check the (x+1)th bit where xth bit is the lowest bit containing 1. If that bit is 1, the current node is in the right subtree of its parent. If that bit is 0, the current node is in the left subtree of its parent. Expand the range by moving l and r pointers.

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

    I made a function that receives a number x and returns info = {value, level, left/right, difference with parent} about it in log(n).
    You can observe that for node x, value of left child is x-dif, value of right child is x+dif. dif reduces by 2 on each level.
    Using this, it becomes easy to process up, left and right queries.
    Here is AC code.
    Here is same code with comments.

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

How do you solve E?

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

How do I solve C?

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

    Find K = sum%3. If its 0, you are done.
    Otherwise, you have to remove at max 2 elements to make it a multiple of 3.
    So there are few cases only that you have. I maintained a vector of pair for both cases, when K is 0 and when its 1. Find for each case the resultant string and take the one with minimum deletions. (Also for more optimization you won't remove digits like 3,6,9 anyway.) Here is the code.

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

How to solve C ? Is this a greedy problem ?

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

What is wrong with this approach of D ?

IF str[i] = 'R' do curr_node = curr_node + 2^(tree_height-curr_height -1 ).

IF str[i] = 'L' do curr_node = curr_node - 2^(tree_height-curr_height -1 ).

IF str[i] = 'U' , I divide curr_node by 2 until it becomes an odd number. If obtained_number+1 is divisible by 4, this implies curr_node is right child of it's parent. currr_node = curr_node - 2^(tree_height-curr_height).

Else currr_node = curr_node + 2^(tree_height-curr_height).

I am maintaing curr_height accordingly at each step and also checking for the bounds.

Getting WA at test case 6.

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

When are the editorials scheduled?

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

the problem C's datas are too strong,,,I had WA many times.

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

Someone pls help me with this. this program runs pretty well on my own computer. But it does not work in the test. It got wa on test 3, where the output should be all YES (and it is on my computer)

25863026

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

for problem A, there are more than 150 hacks in java.what's wrong with java ?

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

    In problem A, Anti-quicksort hack cases work.

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

    Java has a method called Arrays.sort(); that uses a quick sort method to sort an array. Quick sort's average run time is O(nlogn), but it's worst case scenario sort is O(n^2). People used a worst case scenario input/generator to hack many java solutions.

    P.S. To fix this just use Integer instead of int for your array since to sort objects, java uses a merge sort instead, which runs in time.

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

Один из лучших образовательных раундов, благодаря нему можно увидеть насколько плохо работает Arrays.sort в некоторых случаях :D.

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

Could someone please explain this to me: In problem E, I used the solution to go from i to min in array a, and then check min/i and min/i + 1... I understand why and why we check these things ( for every element in a, x1 = a[j]/x, mod = a[j]%x, and if(!mod) just add x to ans, if not, check if(x1+mod<=x-1) add x+1... otherwise... return 0, it's not possible for this x). Now, my question is, is there a proof why this never exceeds the time limit (in fact, it doesn't seem to even get close to exceeding it)? Because the smallest element can be larger than 10^8?

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

    We don't iterate from i = 1 to , instead it's up to . When you want to divide some ai into k sets, each set will be of size . Therefore or . Thus, it's possible to check every case by checking up to the root. Since on each iteration we iterate over our array of size n, the time complexity of the solution is

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

      Thanks for your time, I get that but I submitted a code which goes until m and breaks when a correct solution is found. But I only check m/i and m/i+1, whereas for it to mathematically be correct, I have to check for i+1 and i as well, however I don't and it still works, what am I missing? Edit: This is my submission (28747357)