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

Привет, Codeforces!

В 18.02.2019 18:40 (Московское время) состоится Educational Codeforces Round 60 (рейтинговый для Див. 2).

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

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов и Abizer Reziba Lokhandwala.

Удачи в раунде! Успешных решений!

А вот сообщение от наших друзей из Harbour.Space:

Attention tech specialists!

Harbour.Space Barcelona is proud to announce a collaboration with one of our industrial partners to offer a fully funded scholarship for our one year Master’s in Data Science Programme at HSU Barcelona.

The Scholarship includes:

  • Full coverage of the Programme’s tuition fee (€23,000 value)
  • 3 hours of study a day at Harbour.Space University
  • 4 hours of internship a day with one of our industrial partners
  • €12,000 euros a year (living allowance)

Our data science programme will feature super star teachers like Mike Mirzayanov (Advanced Algorithms and Data Structures), Alexey Dral (Big Data: Map Reduce, Spark, BigTable/HBase) and Alex Dainiak (Discrete Optimisation), plus many more.

Harbour.Space is unique because:

  1. We don’t play by the rules. We bring practicing professionals, not only academic teachers, who come teach for intense, 3 week modules. HSU students are encouraged to experiment, fail, and try again, until they succeed.

  2. We are your home. Harbour.Space is a community of over 40 nationalities, and we're still growing.

  3. We provide an experience. Harbour.Space University is located in Barcelona, one of the most vibrant cities of our time.

If you are interested in the scholarship, fill out the form below and we will contact you about the next steps.

FILL OUT FORM

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

Место Участник Задач решено Штраф
1 kmjp 7 258
2 dreamoon_love_AA 7 269
3 BigBag 7 376
4 Benq 7 573
5 step_by_step 6 178

Поздравляем лучших взломщиков:

Место Участник Число взломов
1 LiM_256 65:-8
2 stefdasca 23:-5
3 Orion 11
4 prohor.b 10
5 parasocial 9
Было сделано 344 успешных и 480 неудачных взломов.

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Задача Участник Штраф
A tataky 0:01
B KieranHorgan 0:03
C step_by_step 0:11
D Gloid 0:11
E Benq 0:10
F TripleM5da 0:34
G tfg 0:16

UPD: Разбор опубликован

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

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

will unsuccessful hacking attempts have penalty?!?

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

Автокомментарий: текст был обновлен пользователем awoo (предыдущая версия, новая версия, сравнить).

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

Good luck to everyone on the round!

P.S. Do not view the previous version of the comment.

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

I love your problems <3

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

Nooor go for it ;)

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

How will the ratings be updated..or in what order since div3 contest is also tomorrow and I believe that the ratings after the educational round gets updated after the hacking ends...

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

Another week of contest overflow :D

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

    Moreover, 'Current or upcoming contests' section includes as many as 18 contests(No. 1125 and 1126 are not shown in the section). Some contest starts after 66 days. :)

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

Hope, I will become legendary grandmaster after round.

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

I wish all participants who can be rated in this contest can't be rated in the next educational rounds!!!

:-)

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

Delayed by 5 minutes :(

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

Hope i become purple again

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

i hope that the problems be short :) sometimes it is hard to undrestand

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

Надеюсь обойдется без говна

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

goooood luck

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

unbalanced

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

The gap of Prob B and Prob C is large.

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

this C made me miss Geometric problems

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

Waiting for someone to post 'me after solving A,B' meme

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

U can't "C"

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

after reading the problem C, I cannot go in the coding phase.

what a problem C is!

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

After a few nice educational rounds i didn't expect this one...

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

What's the most turbulent sea you've seen?

  • South Americans: Drake Sea
  • Chinese: South China Sea
  • Codeforces: Div2 C
»
8 лет назад, скрыть # |
 
Проголосовать: нравится +47 Проголосовать: не нравится

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

Recursion.

contest ended.

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

Нормальный раунд, и цэшка интересная (пацаны, не бейте меня, но можете обоссать)

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

Is D C(n-i(m-1), i) sum over i in [0,n/m]?

Is C binary search over answer d and calculate if Manhattan distance by applying operations till d is less than equal to d?

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

It's just me or both D and E are surprisingly hard compared to past Educational...
Btw, can anyone give me some hints on those ones?

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

How to solve F and G?

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

    My solution for F (pretty tricky, using bitmasks):

    • First, consider a set of 2p bitmasks, in each mask the i-th bit denotes that the i-th letter (0-indexed) in the alphabet is included in the deletion sequence.
    • Take all the bitmasks into a graph. Imagine we're starting at mask 0. The objective is going to a mask that has the smallest string size. Those values can be easily precalculated.
    • From a mask m, it can reach any of the masks having value of (0 ≤ i ≤ p), as long as those masks are allowed to reach (we'll consider that below).
    • If any pair (i, j) (i ≠ j) is not allowed, then the following is true: any substring [L, R] such as L + 1 ≤ R - 1, sL being the i-th alphabet letter, sR being the j-th alphabet letter and those two letters don't occur within substring [L + 1, R - 1]; will form a bitmask — let's denote it as mask1 — that can never be reached. Also, all mask , with (not consisting the i-th bit and j-th bit), will be unreachable as well.
    • If any pair (i, i) is not allowed, then the following is true: any substring [L, R] such as L + 1 ≤ R - 1, sL and sR being the i-th alphabet letter and that letter doesn't occur within substring [L + 1, R - 1]; will also form a bitmask — let's denote it as mask1 again — that can never be reached. Also, as above, all mask , with (not consisting the i-th bit), will be unreachable as well.
    • We can find all occurences of such substrings by traversing to all Ai, j, and then using two pointers to swipe through every possible substring. After this, we can generate the mask by finding which characters are in substring [L + 1, R - 1] — this could be done fairly quickly with the help of prefix sums. The complexity for this part is .
    • After finding each substring, we'll process with the spreading of the "disallowed" attributes from mask1 into all masks originating from it, which doesn't include either bit i or bit j, then every other masks originating from those, recursively. This can be done in a DFS fashion, and each set of parameters (mask1, i, j) will be called at most once. Thus, the complexity for this part is .
    • The final part will be traversing through all the masks. This is a simple DFS traverse, taken time complexity.

    My source code for reference: 50141751

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

It took me 1h and 17m to realise all I had to do in C to get AC is to raise the upper bound of binary search(from 2e9 to 1e15)...

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

omg...C and D make me crazy....

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

can someone tell what's test case 14 in Problem D ? After writing shit Matrix Exponentiation code, I was continously getting WA :((

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

What is the worst case for the most steps on C? I could only find 10^14.

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

I think this educational round was for Div. 1 participants. LOL

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

Hack me pls!

Task A Task B

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

In div2 D I've come up with this formula, so is it right ?

unfortunately did't fit into memory :(

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

When will the "impossible" condition trigger in C?

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

I've got a question regarding the penalty for a wrong submission. Maybe I am wrong, but I thought that a submission which fails one of the examples given in the problem, does not count as failed (it doesn't penalize you). However, I had a penalty for my first submission for problem C, which failed the 2nd example with runtime error. I've seen other contestants who got Wrong Answer on one of the examples given (not for problem C though) and did not get any penalty. I'd appreciate if someone told me when you get a penalty for a submission failed on one of the examples, and when you don't. Thank you.

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

How to solve C?

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

Sorry guys for bothering all this time. Even after repeated attempts, I could not find the bug, so I thought of rewriting my code from scratch and surprisingly it works fine! Thanks for the help!

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

What is the proof that:

is equivalent to dp[n] = dp[n - 1] + dp[n - m]?

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

    dp[n] can be analyzed as the number of ways to get from 0 to n using steps of length m and 1. Let's try to calculate it in a different way: let i be the number of long steps. Then, we have to make n - im short steps and i long ones, so the number of possible ways to permute them is .

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

      So we are basically saying: To calculate number of ways of getting to n using steps of length 1 and m, we have 2 options:

      1) Either the last step is of length 1, so there are dp[n - 1] ways to it.

      2) Or the last step is of length m, so there are dp[n - m] ways to it.

      Thank you very much.

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

    Q1-this part ->> n-i(m-1)=n-i*m+i why we add i at the end ?

    Q2-we use combination not permutation because if the gems arrange them self in a configuration we won't have new configuration am I right ??

    thanks in advance

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

      Ans1 — I am not sure if I understood this question well. But if you mean that why left hand side is equal to right hand side, so the answer would be: because -i is distributed over +m and -1 yielding -i(m) and +i(1).

      Ans2 — We use combination to express that given some i, we want to know the number of ways we can choose i magic gems out of n-i(m-1) magic gems to convert them. This is equivalent to imagining that we have i converted magic gems and n-im unconverted magic gems, and we want to know the number of ways in which these can be permuted with respect to each other.

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

        for Q1 , I mean why we have to add i to the number of gems that we select from in other words why we don't select i from just (n-i*m)

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

          If you select i from n-im then the occupied space will be i*m + (n-im-i)*1 = n-i. You need the occupied space to be n. Note that you take i magic gems and convert them to i*m normal gems. That is, if you took these i gems from x gems, the space will change from x to x-i+im not x+im, because every taken gem removes 1 unit of space and adds m units.

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

hello everyone

in this contest i cheated:(

and i take the code of problem C from my friend

i want this contest to be unrated for me or ban my account or take just problems A and B into account

i am so sorry for this <3

thank you all

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

past is past, learn from it and move forward! Never stop.

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

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

Alternative solution for D,which passed about 10 times faster than matrix exponential: Start with simple DP. DP[i]=answer for line of length i (in particular dp[n] is answer for our problem). Easy transision is: dp[i]=dp[i-1]+dp[i-m]. But we cant count it because n is too big right? Precompute DP up to 10^6(you can actually pick another value like 10^3 lets say). Now lets write recursive func COUNT(n) which while give us answer for line of length n. So if we call our function and n is already<=10^6 we can read the result from our DP. In another case n is pretty big. Lets look at the middle element of this segment and think what can be put in this place. It can be 1, so we'll get two smaller(1/2 size) arrays and the same problem on them to compute our answer. If in this place will be no "1" some segment of length m must be placed there. Lets check all m possibilities and then call our func resursivly on two disjoint segments ( left and right) for each possibility. Sum up results and you will get the answer. Important thing to note is that if we use function COUNT(n) we should store the result of this in (unordered)map, to use it later in another recursive call.

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

can you help me my code for D is to slow and i don't know why https://codeforces.me/contest/1117/submission/50134529

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

In case of D , can we compute the final answer as ,

[f(n), f(n-1)] = [[1,1],[1,0]] * [f(n-1), f(n-m)]

so ,

[ f[n] , f[n-1] ] = [ [1,1],[1,0] ] ^ (n-m) * [f(m),f(1)]

[ f(n), f(n-1) ] = [[1,1],[1,0]]^(n-m) * [2,1]

is this right???

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

After I saw the problem D

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

В тегах задачи C указано ДП. Это какая-то ошибка или существует решение через ДП?

UPD: уже не указано

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

Why the tag of Problem E is "chinese remainder theorem"?

I want to know how to solve E with CRT.

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

Anyone could help me with problem G?It seems that segment tree works but i don't know how to do it.

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

    My solution:

    Let l[i] be the biggest number x such that x < i and a[x-1] > a[i] , consider a[0] = inf . r[i] be the smallest number x such that x > i and a[x+1] > a[i] , consider a[n+1] = inf .

    The answer for [L,R] is sum(min(r[i],R)-max(l[i],L)+1) for L <= i <= R

    Solve the problem offline by using Fenwick tree . (solve min(r[i],R) from R large to R small , max(l[i],L) from L small to L large )

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

RIP My purple dream

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

Can anyone explain how to solve C task please?) I just saw some solutions and there was binary search, how can we use binary search in this task?

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

Any idea when the tutorials would be released?

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

Ура я эксперт

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

How to solve D with matrix binpower?

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

    Observe that if f(n) is the answer for n size. Then, f(n) = f(n — 1) + f(n — m).

    Hint: Since n is very large, we need Matrix Exponentiation. I am not going in details but essentially now you have to make a column matrix of length something like 100. Make a square matrix so that transitions are possible(There's an easy pattern so we can fill the square matrix).

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

Was editorial out?

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

could anyone help me find bug in my code of problem C? thanks in advance! link

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

We got another round and we don't have editorial of this round yet!!!!!!!!!!!!!!!!!!!!!

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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

In Problem C, I tried hard, but can't understand none of the explanations to determine boundaries for binary search(10^14). Can anybody elaborate it please? Thanks

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

    Worst case is when you start at position (0,0) and destination is(1e9,1e9) then manhattan distance is 2*1e9 , also in worst case scenario wind would be against you and it is at max 1e5 so if you can reach destination you should be able to move by 1 every wind cycle therefore 2*1e9*1e5 = 2e14