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

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

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
  • Проголосовать: не нравится

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

I bet you are the problem setter today.

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

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

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

    Still better than 250.

    Everyone gets challenged (at least in my room...).

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

      But everyone who opened the 600 beat me >.>

      For the 300, what's the testcase that kills the solution which checks if the number of connected components is <=1 (instead of checking whether at least one of the components is "good enough")?

      Edit: The check lots of people forgot is {"Y"},{"N"},{"N"}, but my question still stands.

      Edit2: The testcase is {"YNY","YYY","YYY"},{"YNY","YYY","YYY"},{"YNY","YYY","YYY"}. Topcoder chat scrolled away so I can't see who to give credit to, sorry :(

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

        is answer for this test: {"Y"}, {"N"}, {"N"} Impossible? Sorry for stupid question, but i just can't understand trick of this test.

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

          Yes. The trick is that you would see the whole cube should be empty, therefore connected, and you'd think it's all ok if you don't check that it actually covers everything it needs to cover.

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

        And what should be answer for the second? I suppose "Impossible" too?

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

          The second should be possible. Even though the maximal shape is not connected, one of its connected components is good enough.

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

        Thanks for the hint!

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

    Some stupid stuff should pass, they said... It's only 300, they said...

»
10 лет назад, # |
  Проголосовать: нравится +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
»
10 лет назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

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

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

    600 has around 80 successful solutions, 300 has around 55 (much less).

    My sides.

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

How to solve 600?

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится +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

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится +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.

  • »
    »
    10 лет назад, # ^ |
    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]