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

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

Если вы зарегистрированы на тимусе, то вы должны были получить письмо с приглашением на этот контест. Контест состоится в субботу (19 ноября) в 11 МСК.

Вас не должно смущать, что это юниорский чемпионат, так как мы "немного" переборщили со сложностью. Насколько я помню, при отыгрывании Merkurev сдал все задачи за 15 минут до конца контеста, поэтому я думаю, что контест может быть интересен широкому кругу участников, вплоть до сильнейших команд.

Контест проводится по стандартным правилам ACM, длительность — 5 часов. К участию приглашаются как команды (до трех человек), так и одиночные участники. На этих же задачах проводился отбор на чемпионат Урала для уральских команд, поэтому, пожалуйста, не принимайте в нём участие, если вы писали этот отбор.

Контест готовили Um_nik, sivukhin, kb., Tinsane и crassirostris.

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

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

Auto comment: topic has been translated by Um_nik (original revision, translated revision, compare)

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

What is the idea behind problem K?

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

Мне интересно, как решать I(ох уж эти пони), получал стабильно ML-13; а также задача J — я думал, что ответ LCA(u, v), но WA-3, и каюк решению

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

    Ответ — самая близкая к корню вершина из { lca(l, l+1), lca(l+1, l+2), ..., lca(r-1, r) }.

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

    Решение с LCA(u, v) можно довести до правильного, если вместо u и v брать самую левую и самую правую вершину на отрезке [u, v]. Их можно найти, например, храня дерево отрезков на минимальное время входа в вершину в dfs. За log находим нужные вершины запросом к дереву, за log считаем их LCA.

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

Can anyone tell me how to solve I?

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

Full editorial in Russian

Short solution ideas:

A (author Um_nik) — just do what is written in statement

B (Um_nik) — One of the rectangle sides will be on one of triangle sides. If we'll fix that triangle side there will be no more than 2 rectangles. We can find them explicitly. Don't forget about traingles with big angle (>= 90 degrees). Solution can be written in rational numbers in Java/Python but double solution is also OK.

C (Tinsane) — iterate prime numbers, if the number of prime numbers our number have is small and current prime is big then the answer is NO.

D (Um_nik) — it is easy to construct path with length no more than 3. For shorter path write bruteforce starting from T (each number have small number of divisors, it will be fast).

E (sivukhin) — write stupid retrograde analysis, it will work in time. Can be optimised to O(n) using sime prefix sums.

F (sivukhin) — Let the sum of distances traversed by Alice and Bob be L. Then the answer is S / L

G (crassirostris) — just do what is written in statement. May look terrifying, but my solution in Python is easy 40 lines of code (and I'm not a master of Python). Be careful with integer (and even long long) overflow.

H (Um_nik) — every such function must be a permutation. Permutation can be decomposed to some cycles. We want all cycle lengths in our permutation be a divisor of k. Initially we have some cycles and chains, we can join chains and make cycles from chains. We can write an O(3n) DP on subsets but it will be too slow. Notice that chains of length 1 are special — it will lead to O(3n / 2) and even O(2n / 2n2) solutions. Also it can be solved with some smart bruteforces, one of them actually works for n up to 55.

I (kb.) — just do n iterations trying all the rules. Complexity will be O(n2m) which is not fast enough. But we can speed it up using bitsets. Also we can store a pointer to first missing pony in every rule, thus obtaining O(nm) solution.

J (Tinsane) — standard problem with some queries on segments. Let's find LCA (of two vertices) using sparse table, and the build another sparse table to answer queires. Complexity will be , but constant factor is quite large. I_love_Tanya_Romanova got AC with O(log2n) per query solution.

K (Um_nik) — if we can save at least elements then we can get OR of all array, which is obviously maximal. So if then the problem is trivial. Now we'll solve two problems separately: bruteforce for small k and knapsack-like DP for small C.

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

    Thanks for the contest :)

    For problem H, how do you get O(2n / 2n2) ? I saw the 3n / 2 but I thought it might be too slow, so I went to sleep instead :P

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

    For problem D, what's the answer for 5 1000000007 Is 2 4 5 4 1000000008 1000000007 minimal?

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

понял, игнорируйте