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

Автор kimden, история, 7 лет назад, По-английски

Hi!

XIX Open Cup Grand Prix of Belarus takes place on Sunday, February 17, 2019 at 11:00 MSK.

The contest writers are Mediocrity, gepardo, greencis, kimden, and kefaa.

Links to the contest: division 1, division 2. Please do not solve the contest if you solved it in Petrozavodsk.

Let's discuss problems after the contest. Good luck!

UPD. Editorial

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

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

On the contest page it says: "The virtual contest is in progress. You are not allowed to participate".

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

Is the contest not loading for anyone else as well?

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

1) Was the intended solution for J just to precalculate somehow count of all primes and primes of form 4k + 3 up to 1011? If yes, how to do it fast enough?

2) How to solve B? Is there any way to do it without calculation of polynom (x - c1)... (x - cn), where ci = di - dmin?

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

    B: the cumulative distribution function of the answer is when , you need to calculate it multiplying polynomials with divide&conquer. Then you find in linear time.

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

    There were two intended approaches for problem J. One of them is to precalculate count of jimp numbers on blocks of length  ≈ 107 and count the rest using the segmented sieve of Eratosthenes. The second approach is quite complicated. It involves dynamic programming which does sort of "sieve of Eratosthenes" to calculate how many numbers are either prime or not multiple of any of the first k primes. More details may appear later; we would also appreciate if the teams shared ideas of their accepted solutions without precalc.

    Basically, you just need to run the segmented (or block) sieve of Eratosthenes. You can read more about it, for example, here. It works about 20 minutes for the authors to do all precalculations. Note that it's not necessary to calculate primes of form 4k + 1 and 4k + 3 separately, but just all jimp numbers together.

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

What's the expected complexity of C? My O(NlogNlogMAXVAL) gets TLE at test 55. Is there an O(NlogN) solution?

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

How to solve E?

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

    E: The sum of distances is minimized on the centroid of the tree. So if an edge splits the tree into components of size k and n - k it adds min(k, n - k) to the cost. There are ways to split the vertices in 2 sets of size k and n - k, and kk - 2(n - k)n - k - 2k(n - k) trees with an edge connecting those 2 sets. For each such tree we add min(k, n - k) to the answer. The solution works in . It seems that the only reason for n ≤ 5000 is so I spend half the contest optimizing solution.

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

too many errors in samples :(

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

    Could you please tell which particular problems had errors in their samples? We are only aware of typos in Notes section in problem C, where 3 values in sample explanation are wrong. But it seems that it didn't cause any troubles for many teams in passing problem C. (UPD: Div2 problems had some typos, too.)

    Anyway, sorry for the inconvenience, we'll be more careful next time.

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

      (Div2) For example O, P, i catch strange "Check failed" in G. It's not problem a big problem for a lot of people, that's just affected me enough, bcs my incorrect program gave the same result for incorrect sample :)

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

How to solve A?

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

    First, ask about all the vertices. Then for each i ask about all the vertices except the i-th one. If the area decreases, then i-th vertex is the vertex of convex hull. Notice that vertices of convex hull are in the same order as the vertices of the polygon. Now we know that convex hull is p1, p2, ..., pk. To find the area of the polygon we need to subtract from area of convex hull areas of polygons of the form pi, pi + 1, ..., pi + 1 - 1, pi + 1. We can find those areas recursively with the same idea.

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

      Also, if the area of convex hull is 0, we should set the area of polygon to 0 and stop, otherwise we can ask about this polygon infinitely.

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

      How do you show that this asks no more than (n(n - 1)) / 2 queries? We could show O(n2) by arguing about how many times a vertex can be a "hole" (ie. the vertex in the except clause) -- but couldn't get the constant.

      Also, did anyone else get Presentation Error? We checked number / validity of queries with asserts, and can't figure out why it's happening.

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

        In each recursion call we ask one question about all vertices and one question about each vertex which is not on convex hull. So, for each vertex the number of questions about it is the depth of recursion when it becomes on convex hull. On the first recursion call we find at least 3 vertices on convex hull. Then on each depth of the recursion we find at least 1 vertex on convex hull. Also there are no more than n - 2 recursion calls, because on each recursion call we find at least one vertex on convex hull, but on the first one we find 3. So overall the number of questions is no more than 3 + 2 + 3 + 4 + ... + (n - 2) + (n - 2) = n(n - 1) / 2 + 1. Actually the number of queries is a bit less because when there are only 3 remaining vertices, we know that all of them are the convex hull.

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

What is the solution to D?

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

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