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

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

Hello Codeforces,

I would like to invite you all to participate in the 2017 JUST Programming Contest 2.0 of Jordan University of Science and Technology. The contest was originally held on 1st of April, and it will launch in Codeforces Gym tomorrow; Friday 7 April 2017 13:00 UTC.

The problems were prepared by justHusam and Lvitsa.

Thanks to Vendetta. for testing the problem set.

The duration of the contest is 4 hours, and the registration will be open 6 hours before the start of the contest.

Good luck for everyone, and I wish you all Accepted solutions.

UPD: Registration is currently open.

UPD: The contest will start in 30 minutes.

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

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

Is there gonna be editorial for the problems?

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

How to solve A?

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

How to solve J?

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

    Hi! Quite late, but hopefully it will help someone. Perhaps my solution is too complicated, I would love some feedback.

    1. Remove all such arrays which are wholly contained within another array.

    2. Model the problem as a graph. Each array is connected to every other array. The edge weight is the "saving" you do when you connect them, i.e., the number of elements in common from one end. We can assume A->B means overlap A's right end with B's left end. Hence, dist[A][B]!=dist[B][A]. I took the edge weights as negative.

    3. Create a dummy vertex connected to every other vertex with edge weight 0.

    4. TSP (it should run as you have at most 16 vertices).

    5. In my case, as edge weights were negative, I simply output the sum of lengths of all arrays + total saving.

    Hope this helps :) Please let me know if some part of my explanation is not clear...

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

How to solve B by DP ?

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

    Make dp, dp[i] — count of ways we can divide prefix of length i into beautiful substrings. We want to calc dp[i]. Iterate j from i to 1 and break when not all numbers in [j, i] are unique otherwise add dp[j — 1] to dp[i] (making split before position j). Initial values: dp[0] = 1 (if you have indexes from 1). Solution O(n * a), where a = 10. There is also solution O(n) using two pointers.

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

      Can you explain the Two pointers solution ?

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

        Our dp can be presented as follows: f[i] = sum(f[i — 1] + .. + f[j — 1]), where j is the least index such that substring [j, i] is beautiful. When we are going to (i + 1) j won't decrease. So we can store our current sum of f[j..i] and when we want to calculate f[i + 1] subtract f[j] from sum and increase j by 1 while [j, i] isn't beautiful. Code