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

Автор satyam343, 16 месяцев назад, По-английски

We invite you to participate in CodeChef’s Starters 72, this Wednesday, 4th January.

Time: 8 PM — 11:00 PM IST

Joining us on the problem setting panel are:

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest.

The video editorials of the problems will be available for all users for 1 day as soon as the contest ends, after which they will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

Hope to see you participating. Good Luck!

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

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

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

»
16 месяцев назад, # |
  Проголосовать: нравится +25 Проголосовать: не нравится

Test comment. (Blog doesn't show up on recent actions)

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

How to solve No Sequence

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

    Hint: attempt to set every element in the answer to 1 at first, then decrement when you need, some small optimization may be needed

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

    Cases $$$k = 1, 2$$$ are trivial. Notice that some element of $$$\{s - 1, s, s + 1\}$$$ should be divisible by $$$k$$$. Because $$$k \geq 3$$$ it must be exactly one element if solution exists. That way we found $$$b_1$$$. Solve recursively for others.

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

    I have an easy intuitive solution for that.
    Just take a var = 0 and check for decreasing powers of K(from n-1 to 0), whether adding/subtracting this to/from var will result in bringing var closer to s. Fill suitably 1 or -1 at this index in the answer array, and modify var.
    After traversing all powers of K, if var != s, then print -2, else print the answer array.
    My submission
    Note why this works is because of the fact that K^N will always be greater than sum of K^(N-1) + K^(N-2) + .... + K + 1, so K^N will have the greatest hand in determining the closeness of var to required s.

»
16 месяцев назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Story of the contest: I am happy with my performance solving (only !) 2 problems in a div2 round, and not even a speed solve

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

did anyone solve XOR Tree using multiset(to find the greatest xor value of leaf)?

»
16 месяцев назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

Edit: I am deeply ashamed of myself to discover that I had an integer overflow in pre-computation.

How to solve Good Arrangements ?

My idea is to fix a starting value, and then using some combinatorics formula to calculate arrangements. Am I in the right direction ?

The formula I thought of:
  • »
    »
    16 месяцев назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    We need to fix not only the starting element — $$$v$$$ but also the amount of it in the beginning — $$$c$$$. Then your formulas are almost correct

  • »
    »
    16 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

    Try to fix the number of indices i such that b[i] is the prefix maximum, then, since we know that maximums will occur in increasing order and minimums in decreasing order, we only need to choose the indices where we will keep the maximums.

    there is a caveat, though, you need to make sure that all places other than the maximums will surely be minimums to avoid overcounting; try to figure that out, it isn't very hard.

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

    Yeah, your formula is correct