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

Обратите внимание, что мы напряглись и подготовили дополнительные задачи для Div 1. Таким образом, параллельно с отборочным раундом будут проведены Codeforces Round 440 Div.1 и Div.2 (рейтинговые раунды для обоих дивизионов — всё как вы любите). Участвуют все!

Добрый день.

15-го октября в 11:05 (московское время) стартует Отборочный Раунд 2 (и открытые раунды для обоих дивизионов по его мотивам) олимпиады для школьников Технокубок 2018. Раунд будет длиться два часа, участникам будут предложены 6 задач. По его результатам лучшие участники (но не более 45% от общего числа участников раунда) будут приглашены на финальный этап в Москву. Для регистрации на раунды и участия перейдите по ссылке. Не забудьте заранее зарегистрироваться на раунд. Впрочем, если забудете — не беда. Через 10 минут после старта будет открыта дополнительная регистрация для опоздавших (ее длительность — 20 минут).

Зарегистрироваться на Отборочный Раунд 2 →
Соревнование открыто для всех в виде отдельных раундов для первого и второго дивизионов.
Для всех участников всех трех редакций этого соревнования будет пересчитан рейтинг.

Напомним, что согласно правилам раундов Codeforces во время соревнования ваши решения будут тестироваться только на претестах (предварительном и неполном наборе тестов), а системное тестирование состоится после окончания раунда. Обратите внимание, что претесты не покрывают все возможные случаи входных данных, поэтому тщательно тестируйте свои программы! После прохождения претестов у вас будет возможность заблокировать решение, тем самым получив привилегию искать ошибки и взламывать чужие решения, но отказавшись от возможности перепослать ваше решение при каких-либо обстоятельствах (например, даже если вы найдете ошибку или вас взломают). Со временем задачи падают в стоимости. После системного тестирования учитываются только полные решения. Подробнее про правила соревнований можно прочитать по ссылкам:

Регистрация на олимпиаду Технокубок еще открыта. На кону — значительные квоты при поступлении в престижные технические вузы России и ценные призы. Если вы — школьник 8-11 классов и пока не зарегистрировались на Технокубок, то самое время сделать это:

Зарегистрироваться на олимпиаду →

В финал соревнования будут приглашены лучшие участники каждого из отборочных раундов (но не более 45% от общего числа участников раунда).

Желаем удачи на олимпиаде,
MikeMirzayanov и команда Технокубка

Опубликован разбор.

Поздравляем победителей!

Отборочный раунд Технокубка:

  1. Mikhniuk
  2. scanhex
  3. Krisha
  4. lis
  5. FalseMirror

Div. 1:

  1. khadaev
  2. Errichto
  3. eddy1021
  4. FizzyDavid
  5. fateice

Div. 2:

  1. wdmmsyf
  2. Legilimens2023
  3. destinydrifter
  4. oscar114514
  5. OMS
  • Проголосовать: нравится
  • +188
  • Проголосовать: не нравится

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

Пересекается с GP of SPb :(

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

Mandatory comment- "Hope the problem statements are as short as this blog".

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

Clash with OpenCup. ;(

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

Is it me or is the contest title is longer than the announcement :3

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

I guess it's the first time that we don't see any "thanks" or even any username in an announcement :D

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

This is like the shortest announcement ever of all time.

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

A good time for Chinese students!

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

I have an onsite contest after 15mins for 5 hours, and then I can take part in this cf round. A good time for me.

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

I have doubt.

When I opened 'contests' page, it showed me two separate contests(div1 and div2), but in the announcement it is given (Div1 + Div2). Which one it is going to be ? MikeMirzayanov

UPD : when I posted this comment, there were only 2 contests. (contests 440Div1 , 440Div2).

That's why I got confused. Right now contests page is fully updated. NH_Apu

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

I Wish everyone positive rating!

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

why do timing varies a lot recently ??

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

I hope I won't get a WA on problem A, the way it happened in the previous contest :(

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

It will be at 3 AM here in Colombia. Guess is a good way to start a Sunday ¯_(ツ)_/¯ .

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

2 PM in Bangladesh..Surely the best time except for missing lunch

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

The Terms of agreement when registering is in Russian "Вы подтверждаете, что будете работать самостоятельно во всех этапах Технокубка и не будете нарушать какие-либо другие правила." So I'm wondering whether an English version of problem statements will be given during the real contest. Can anyone explain about this a little bit? Thanks a lot.

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

gl hf

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

Надеюсь в этот раз MikeMirzayanov не промахнётся по скриптам.

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

number of problems and the difficulty is about the 1st round ? because that round was easier than ususal

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

What's the "Practice Round 2"?

EDIT: never mind, seems to be for Technocup official participants only

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

Hope there will be no geometry problems

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

May be it's a silly question.

but what does "00:04" like things below every submission means??

is it time of submission or what

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

    You mean the time that is shown below the submission during the contest.

    Its the time when you've submitted the solution after the start of the contest. '00:04' Would mean that you've submitted the solution after 4 minutes

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

How long will the contest last?

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

have no time to receive it :D

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

Why can I register for both Codeforces Round 440 (Div 1) and Technocup 2018 round 2?

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

How many problems?

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

YouHaveShort Blog.

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

Registration button didn't work for me...

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

Mandatory comment- "Thankyou for the short problem statements".

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

Disclaimer: My argument may be wrong, and if it is, I don't mean to offend anyone, so apologies in advance.
The contestant who is currently second (at the time of commenting) in the leaderboard looks mighty suspicious. He has solves solves for 3 different problems in the space of 6 minutes, including solving D in 2 minutes. Check out his submissions.

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

In Div-1 B, just ask n queries of the form (i, 0) and n queries of the form (0, i).
Now, if you know p[i], you can get p[j] using p[i] ^ query(i, 0) ^ query(j, 0).
And if you know b[i], you can get b[j] using b[i] ^ query(0, i) ^ query(0, j).

Now, one by one, fix the the value of p[0] from 0 to n-1. Then you can recover the whole permutation p[].
You know that b[p[0]] = 0, so you can recover the whole inverse permutation b[] as well.

Check if both are valid. All elements of p[] are distinct and 0 <= p[i] < n && b[p[i]] = i.
It this is true, this is a valid answer. Simply count the total and print any one of these.

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

Ok, so what are the hacks on B? Thanks for short statements, by the way.

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

literally 1 sec from submitting D and the contest ends :/ .

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

How to solve Div-1 C?

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

Hints for Div2 E?

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

how to do C?? i submitted in last 3 min..

if(x&1 || x<4) ans=-1;

if(x%4) ans=x/4

else ans=[(x-6)/4]+1

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

wait whoops i forgot to flush output for final answer for B and i still passed pretests even though the problem warns against this, i hope i pass systest...

EDIT @below: Nope, I used '\n' to end my line, I really hope I'm okay...

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

пипец чет сложна

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

Hacks for C?

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

Fun solution for Div.1 D:

The main observation is that the distance for every pair is either 0, 1, 2 or 3.

You can easily find the number of pairs with distance 1 (they have gcd ≠ 1 and this is a well known problem).

For the number of pairs with distance 2 the following condition should be true:

lp(X) * lp(Y) <  = n, where {X, Y} is the pair (lp(x) here is the least prime divisor of x).

That's true, because we can have a path like X -> (lp[x] * lp(y)) -> Y.

And now we are left with pairs with length 3. The following conditions should be true:

lp(X) * lp(Y) > n and max(lp(X), lp(Y)) * 2 <  = n, where {X, Y} is the pair.

That's true, because we can have a path like X -> (2 * lp[x]) -> (2 * lp(y)) -> Y.

Well if we have found the number of pairs of distance 2 and we count the number of pairs for which max(lp(X), lp(Y)) * 2 <  = n is true and then remove the number of pairs with distance 2 we will get the number of pairs with distance 3.

Well now the only part is how to count the number of pairs with the given two conditions. We can do a fenwick tree on the values. Here is the code.

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

Does any one solved problem div2 C using DFS / BFS or Recursion or dp ?

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

May be rename to Mathforces?

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

For some reason, for Div 2 C I thought that the queries themselves had to be prime to be valid, and I would need to print out -1 if the queried number wasn't prime.

I wrote up the entire code of getting all the primes less than sqrt(1 billion) by checking for primality with a sieve. Then I checked for each query number if it was not prime by seeing if it could be divided by any of these prime numbers < sqrt(1 billion) I found through the seive, and then I realized I had interpreted the problem wrong and had added more requirements than necessary!

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

waiting for system test.

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

When will the system test start?

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

Come on, khadaev. We agreed to submit on 1:30 -_-

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

How to solve div.2 D? It's it about circles of permutation?

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

    It's about n^2 brute-force. You can query (0..n-1, 0) and (0,0..n-1) and try every position of b0, say fix b0=i.Then reconstruct p from pi=b0^(saved query(i, 0) value). Finally, check whether it is a valid permutation and consistent with the queries.

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

      Er...set b0 to i?Are you mean that assume b0 is i,then Query(0,0-n-1) and Query(0-n-1,0)...?

      It seems good...But how to construct all the p values or determine the value of the true b0...?

      Sorry for my late reply and my low intelligence...

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

        Let Q0, Q1 be arrays of length N and Query(X, Y) be query value — i.e. P[X] xor B[Y].

        We can save Q0[i] = Query(i, 0) and Q1[i] = Query(0, i) for all 0<=i<N.

        Then the brute force begins.

        1. We fix b[0] = k

        2. We can reconstruct P by setting P[i] = Q0[i] xor k.

        3. Now we check whether P is a valid permutation.

        4. If it is valid, then we check P against our saved queries, namely Q1.

        5 Repeat from 1 to 4 for all 0<=k<N.

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

I think div.2E is a problem of combination number,but I can't get the solution.

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

Div.2D: I wrote all my queries to stdout and flushed, then read the all of the answers one by one, and my submission got an ILE? Somebody wrote one query to stdout and then read the answer at once, then he passed the pretest? Is it my fault? My Submissions:

cstdio version

iostream version

Practice submission(query and then read at once):

Practice version

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

del

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

I submitted solution to B after hack to my solution which got accepted. To recheck it i submitted my previous solution again and it showed the wrong answer. Now my solution (correct one) is not getting evaluated. Will they not consider my correct solution. :( EDIT : They evaluated it :)

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

NOOOOOOOOO!!!!!!!In Div2 D During the contest I read the answer of 2*n times together and I got an ILE…… After contest I tried read every answer after questioning I got AC …… Oh my goodness……

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

How to solve Div.1 E?

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

    I think the main problem is constructing compressed tree for that k vertices. I remember it is to solve this: https://open.kattis.com/problems/optimistan.

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

    Pick a pair of special vertexes U,V that are as far from each other as possible. Construct a chain that connects them (these are the points with d(U,W)+d(W,V)=d(U,V) ordered by distance from U). Consider subtrees rooted at each vertex from this chain. We can easily split all vertexes into these subtrees. The distances to each vertex X from X's root Y equals to d(U,X)-d(U,Y). So we may treat roots as special vertexes. Most of subtrees will have only one special vertex — the root. They may be processed in O(N) in total. For the other subtrees we recursively call the same procedure.

    This process seems to terminate quickly. On every step each subtree will lose 2 special vertex, but it may possibly generate some new. The more subtrees there are, the faster the special vertexes are lost. It seems all vertexes will be processed in O(K) iterations and problem is solved in O(KN).

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

В задаче B(div2) проходят решения, выдающие ответ 1 или 3 на тест 3 2 3 3 1

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

Good, lucky problems, good contest as well as author!

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

My screencast

Hope you find it interesting!

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

For problem B

for k==2 how is it max(a[0],a[n-1])

  • »
    »
    9 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    1. Seeing, that you can achieve it, is pretty easy. You can take that one element as one segment, and the rest as the other.

    2. Let's assume we achieve an answer x such that x > max(a0, an - 1). If this element is in the first segment, then the first segment's value should be x, but since x > a0 the score will be at most a0. Same goes for the second segment, so x can be in neither segment, which is contradiction.

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

    Splitting of array a of n elements into 2 subarray,it must be a prefix and a suffix. for the minimum to be larger, we make the 2 subsegments [0,n-2] and [n-1, n-1] or [0, 0] and [1,n-1]

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

      subsegment can be:

      [0,n-3][n-2,n-1] like that...

      why these two??

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

        2 subsegment : [0, x], [x+1, n-1] (0 <= x < n-1)

        the answer is max(mininum in [0, x], mininum in [x+1, n-1])

        so :

        mininum in [0, 0](it is a[0]) is larger than mininum in [0, x]

        mininum in [n-1, n-1](it is a[n-1]) is larger than mininum in [x+1, n-1]

        when a[0]>a[n-1] a[0] is larger than mininum in [0, x] and mininum in [x+1, n-1](for each x : 0 <= x < n-1)

        when a[0]<a[n-1] a[n-1] is larger than mininum in [0, x] and mininum in [x+1, n-1](for each x : 0 <= x < n-1)

        so for the minimum to be larger, we make the 2 subsegments [0,n-2] and [n-1, n-1] or [0, 0] and [1,n-1]

        sorry, my English is not very good, but you can try to understand it. :)

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

Oh..There are so many hacks today! You see There are about one thousand and seven hundred people solved ABC during the contest. So do I. But my solution for B got a FST... Because I defined the mininum by -1e9+7 instead of -(1e9+7).. But I still got rank 180..Because I hacked eleven people :P

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

Will there be an editorial?

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

http://codeforces.me/contest/872/submission/31353320

check this solution for Div2D.

When something likes "5000 xor 4191" happens, will it get Runtime Error ? I think it will

but why it didn't happen ?

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

Is the editorial published ?

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

How you guys came up with Div2-C . I mean is it writing bruteforce than generalizing it Or there is some other way to approach for solution?

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

    I will try to explain a possible approach.

    First, if you want to represent n as a sum with lots of summands, those summands have to be small. Therefore you should ask yourself, what is the smallest suitable summand? It is 4. Can you use only 4? Only if n % 4 == 0. What about the other remainders modulo 4? You are obliged to use something else apart from 4.

    The next composite number is 6. You can see that if n % 4 == 2, using one 6 and all 4 is optimal. But you cannot obtain any odd n using only 4 and 6.

    Hence you need to use one more number. Maybe 8? No 8 is not useful as 4+4=8. Maybe 9? Yes! Using one 9 and all 4 you can obtain all n % 4 == 1.

    The only remaining case is n % 4 == 3. Can you get it using only 4, 6, 9? The answer is yes as 6 + 9 % 4 == 3. The issue is that this is no more trivially optimal and you have to check the optimality. However, checking it is super-easy, as the smallest useful number (i.e. it is composite and it cannot be generated as a sum of 4, 6, 9) is bigger than 6+9 = 15 and therefore using 6+9 is optimal if n % 4 == 3.

    p.s. I have ignored all small cases. As a byproduct of the explanations I have given ,those are all impossible (1, 2, 3, 5, 7, 11).

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

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

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

Ну так что, проходят первые 100?

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

And how many participants went to the final?

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

Does anybody know why I receive "Denial of judgement" for sources 31428657 and 31428722 ? The error on test 88 is : Can't compile file: Compilation process returned error: execution failed because of unknown invocation error