Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Автор MikeMirzayanov, история, 8 лет назад, По-русски

Добро пожаловать на 2016-2017 CT S03E05: Codeforces Trainings Season 3 Episode 5 (2016 Stanford Local Programming Contest, Extended). Продолжительность тренировки — 4 часа 30 минут. Тренировка открыта как для команд, так и для индивидуальных участников. После ее окончания вы можете дорешивать задачи тренировки или поучаствовать в ней виртуально, если не смогли принять участие одновременно со всеми. Пожалуйста, участвуйте в тренировке честно.

Перейдите в раздел Тренировки для регистрации и участия.

Ориентировочный старт: 5 октября 2016 г., 16:10 (Московское время).

Так как это тренировка, то возможно набор задач будет расширен, если для значительного количества участников он окажется простым.

Условия задач будут на английском языке, ведь мы же готовимся к ACM-ICPC!

Удачи!

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

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

Aha, a nice try! This is very creative.

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

He forgot to append '\n' character. That is why the teacher is angry.

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится
    #include <stdio.h>
    int main(void)
    {
        int myCuteCount;
        for(myCuteCount = 1;myCuteCount <= 500;myCuteCount++)
            printf("I will not forget to append '\n'.");
        return 0;
    }
    
»
8 лет назад, # |
Rev. 2   Проголосовать: нравится -29 Проголосовать: не нравится
#include <stdio.h>
int main(void)
{
    int myCuteCount;
    for(myCuteCount = 1;myCuteCount <= 500;myCuteCount++)
        printf("I will not throw junk comments in codeforces.\n");
    return 0;
}
»
8 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

How to view solution of other users in Gym contest which I haven't solved ?

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

How to solve A, H and J?

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

    In problem A, we're asked only the smallest 100 combinations in the worst case, so we can keep track of the smallest k combinations we've seen so far in an array, and whenever the array exceeds k (after sorting) we remove elements from the back.

    • Initially, put all v1, i into the ans array.
    • Then process piece types one by one. To process piece type i, for all current values x from the ans array and all values vi, j we push value x + vi, j to ans. After adding all new values, we must delete the old ones (we can do it with one array by swapping new elements with old ones or have two arrays and swap them at each piece type). When we're done removing old elements, we sort the ans array and remove elements from the back until size is  ≤ k.
    • Finally, print the contains of the ans array.
    • We do m2 operations to process each type and logm2 for sorting the ans array, and there are m piece types, so in total we do m3 + m * logm2 operations. Total complexity: O(m3).

    PS: The technique used in this problem is known as Beam Search, and is widely used in optimization problems.

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

    H: Let's compute the area of the polygon using pseudoscalar product (not sure if this is the right term in English, in 2D it is equal to x1y2 - x2y1). To do that, we just sum up all the oriented areas of triangles (ai, ai + 1, (0, 0)). Note that if we reverse the order, the area will be exactly the opposite. That is why, we can conclude the answer from the sign of the area computed this way.

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

    H: For any point X in the polygon, the sum of the signed angles PiXPi + 1 is either , or  - 2π, depending on the polygon's orientation. From outside the polygon, the sum is 0.

    So all we need to do is find a point in the polygon. I took the midpoint of a non-vertical edge, perturbed it by a small amount upwards and downwards, and computed the sum for these two points.

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

    J: First sort all points by x-coordinate. Now brute force over all combinations of the minimum and maximum y for the rectangle. For each min-max pair, we can find all rectangles containing n/2+1 points using a two-pointer approach, where the pointers mark the left and right boundaries of the rectangle. When we march the left pointer forwards, we lose some points, so we must march the right pointer forwards as well. Total time is O(n3).

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

Is there any tutorial available?? Thank you in advance

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

Is there any tutorial available? Thank you in advance

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

how to solve L?

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

Can anyone help me with J. Thanks in advance

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

    for each 2 X's --> for each Y --> do binary search

    the idea is : you need 2 points( upper-left , lower-right )( 2 X's , 2 Y's )

    the 2 X's may be the same and the 2 Y's may be the same

    the bruteforce solution is O(n^4) ( bad )

    to reduce the complexity a little bit you can try :

    every 2 X's and 1 Y : binary search the other Y

    this solution is O(n^3 logn) ( good enough to pass )

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

      every 2 X's , 1 Y and binary search the other Y

      There is no need to do binary search. If you have sorted array of points between X1 and X2 (which you probably need for binary search as well), you can just try pairs .

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

    hhhh

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

in problem G-Ground Defence :

i'm trying to solve it with segment tree ,but how to handle lazy propagation ??

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

Just a key observation for not being stuck for ever in problem F: the length of the least path between two points with the same latitude IS NOT the length of the arc of the maximal circle of the sphere that contains both points.

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

How to solve L and M?

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

How to solve problem K?

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

How to solve C?

I compute probabilities for each triple (t, n, nd) (where t — time, n — number of unique cards, nd — number of dublicates, nd < d). But I get expected time 10.414 for the second sample instead of 10.185.

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

how to solve B??

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

How to solve F?)

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

Oh, I was solving J for one hour because I coded a solution with complexity O(T*N^3) for stress testing in the beginning and then tried to come up with a fast solution. In the end, I just sent the O(T*N^3) and it got accepted in about 100 ms :D

Is this the expected complexity, I thought it would be too slow?

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

больше не будет тренировок таких?