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

Автор Xellos, 12 лет назад, По-английски

The last blog got downvote bombed into oblivion, but I have enough contribution to spare.

TC SRM 638 takes place soon (ಠ_ಠ).

Feel free to discuss the problems here after the round ends (because TC apparently doesn't have placeholders for new matches in its forum anymore...).

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

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

I bet you are the problem setter today.

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

Start with the hard problem, they said... It's only 800, they said...

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

TC apparently doesn't have placeholders for new matches in its forum anymore...

From Chat Room 1:

vexorian> t-mac: also create for 637 it has been missing
...
t-mac> vexorian: I'll get that fixed soon, sorry about that
»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

It seems that the nubmer of people solved 300 is nearly same as the number of who solved 600 :(

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

How to solve 600?

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

    Considered the largest wolf wolfi, if wolfj + wolfi ≤ limit,then this wolfj is free, it can be anywhere in the sequence. But somehow there are some wolves can only be in the left of the largest one, some should only be in the right. Now we get two small subproblems. You can use divide-and-conquer to solve it.:D

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

    Consider f(start, end) = number of possible permutations on the subsequence [start — end]:

    • If end < start just return 1;

    Otherwise: - Find the smallest wolf and remember its position min;

    • Find the largest range [minStart, min] such that minStart <= start and the sum of wolf[i] + wolf[min] <= maxSizeSum for every i in this range;

    • Likewise find the largest range [min, maxEnd] such that maxEnd <= end and the sum of wolf[min] + wolf[i] <= maxSizeSum for every i in this range;

    • Swap positions min and minStart;

    • The answer will be: f(start, minStart — 1) * (maxEnd — minStart + 1) * f(minStart + 1, maxEnd) * f(maxEnd + 1, end).

    This is because in the range [minStart — maxEnd] for every i in this range wolf[min] + wolf[i] <= maxSizeSum so wolf[min] can occupy any position within this range but can't go outside this range. So you are left with calculating the number of possible permutations in this range such that wolf[min] isn't there and multiply by the length of the range because wolf[min] can occupy any position. Of course you still have to multiply by the number of permutation on the left and right side of this range which is f(start, minStart -1) and f(maxEnd + 1, end) respectively.

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

    There is a simple solution. Find a smallest element. Find the number of places (it can go right and left as long as swapping rule is not violated) it can be in.Let it be k. Now, remove that element from the array.Let the new array be v' Answer is ans(v)=k*(ans(v') .
    This is O(n^2) (using recursion,n steps at each level)
    Credits : [user:msaikrishna17394]