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

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

Привет, Codeforces!

30 сентября 2016 года в 17:05 Мск состоится Codeforces Round #374 (Div. 2) для участников из второго дивизиона. Участники первого дивизиона традиционно могут участвовать вне конкурса. Обратите внимание на необычное время проведения.

Это мой второй раунд на Codeforces, я старался сделать задачи интересными для всех, поэтому рекомендую прочитать условия всех задач! Желаю всем участникам раунда найти что-то новое и интересное для себя, и, естественно, быстрых решений и высокого рейтинга!

Хочу поблагодарить Михаила MikeMirzayanov Мирзаянова за замечательные платформы Codeforces и Polygon, за помощь в придумывании задач и их подготовке, своих очень хороших друзей Данила danilka.pro Сагунова также за помощь в подготовке соревнования и Ивана BledDest Андросова за прорешивание раунда.

Участникам будет предложено 5 задач и 2 часа на их решение. Разбалловка будет традиционно объявлена ближе к началу раунда. :)

Разбалловка почти стандартная: 500-1000-1500-2000-2750

UPD: Разбор

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

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

30 September

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

Unfortunately, this round will be conflict with Jordan-cpc :/

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

I am loving the that timing is being rotated around! It unfortunately makes a lot of people unhappy but I think it is still a great opportunity for people in different time zones, so nobody misses out.

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

"Unusual" is the new usual.

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

wish to see a programming contest not a hacking contest :D

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

bad round PS : one of my friend has comment it when we has class, sorry author :((

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

one's day may be night for others. so we should appreciate this "unusual" time.

»
10 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится -56 Проголосовать: не нравится

my best friens Danil danilka.pro Sagunov also for help in preparing the round

what does "friens" mean??

UPD: fixed.

»
10 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится -40 Проголосовать: не нравится

good luck

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

salam

are problems sorted in order of their difficulty?

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

Why Kotlin is not allowed in this round? It seems to be the only language missing compared to rounds 371-373. Edit: In the end system accepted Kotlin submissions too.

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

Round 374.
374 = 2 × 11 × 17 , Sphenic Number

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

I hope the platform will be stable today. Currently there are 7+ pages of pending submissions....

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

The judge queue of practice problems is very very very long now. I hope this issue will be resolved soon and have no impact on this round.

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

Hit like if you think your rate will be increased today :v

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

I hope that I have become better.

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

Score distribution ?

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

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

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

After reinstalling windows, I am unable hack in firefox.

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

the cool trick in div2 A is that you shouldn't test all samples on your code :v

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

Quick question, if I can't get pretests passed for anything I submitted, I'm still eligible for rating drop, right?

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

So codeforces allows submit the same code now?

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

Div2B hack?

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

Nice contest.. Anyone can tell me how to solve problem D??

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

    First, if the amount of negative numbers is even, we want to make it odd. So we pick the number with smallest absolute value and apply operation until it's signal is swapped (sometimes we don't have enough operations but it doesn't matter, just keep trying until the signal is swapped or until you don't have more operations).

    Then, we simulate the process. While we can apply operation at least one more time, we apply it to the number with smallest absolute value at each step, raising its absolute value. We can use a priority queue to simulate this. Turn all numbers into positive numbers and store the signal separatedly, so it's easier to work with the priority queue.

    Then, after we used all available operations, we push the results to an array and print the answer.

    This solution is correct because it is possible to prove that for any set S with only positive numbers, if we can increase any number by K, the total product is maximized if we always pick the smallest one.

    Code: http://mirror.codeforces.com/contest/721/submission/21037453

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

      Can you prove that why choose smallest abs value and apply opration on it in first step is true ??

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

        Because if we pick the smallest abs number, we will waste a minimum number of operations to swap its signal. These operations will only reduce the abs value of our product or increase it by a smaller value than if we used the operation to increase other value, so we dont want to do a lot of these operations because we want to maximize the abs product (and have an odd amount of negative numbers so the signal of the product is negative and then the total product is the minimum)

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

        Consider that you have two elements ai and aj, |ai| < |aj|. Let m be the smallest number of operations required to change the sign of aj. If you apply them to aj, you will get two numbers, ai and new aj, and now |aj| (the new one)  = m·x - |aj|. If you apply all those m operations to ai instead (there might be some better ways, but let's consider this), there will be new ai: |ai| (the new one)  = m·x - |ai|, and aj will remain unchanged. |aj| > |ai|, m·x - |ai| > m·x - |aj|, and you need to maximize the absolute value of product, so you get a worse situation if you change an element with non-minimum absolute value.

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

      But let's say we have the numbers -2 and 1, an x=4 and t=2 Then by your algorith we wouldn't do anything and leave the product as -2. But we could actually add 4 to the first one and subtract 4 from the second one and get the product 2*(-3)=-6, which is smaller What is wrong in my logic?

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

How to solve C guys?

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

Is there a special algorithm to do C? I kept getting time limit with a breadth and depth first search.

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

    I was on the same boat for a while. The trick (for me, at least) was topological sorting.

  • »
    »
    10 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +5 Проголосовать: не нравится
    1. Do a topological sort of vertices.
    2. For each vertex (in a topological order) calculate minCost[v][pathLength + 1] = minCost[parent][pathLength] + timeToTravelFrom[parent][v] and save where you came from previousVertex[v][pathLength] = parent.

    pathLength is the number of vertices on some path from vertex 1 to the current vertex v. Among all the possible paths from 1 to v which have pathLength vertices between them, there exists the shortest path. We track the cost of that path here minCost[v][pathLength + 1].

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

      Can you clarify your answer regarding nodes which have multiple parents? If we just loop through all parents of a node and all pathlengths, we get O(n^2 * m). This would be similar to my solution, which barely passed the time limit after contest. Other people have solved it way faster and I'm trying to figure out how...

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

        Sure.

        Let's consider, for example, a DAG with 6 vertices: v1, v2, v3, v4, v5, v6.
        The goal is to arrange all vertices in layers or floors. Let's stick to floors.
        Imagine there is a 6-storey building:
        [ floor 6 ]
        [ floor 5 ]
        [ floor 4 ]
        [ floor 3 ]
        [ floor 2 ]
        [ floor 1 ]

        Floors somehow (we don't know yet how) correspond to vertices in a graph. We only know the identity of 2 vertices: v1 is [ floor 1 ] and v6 is [ floor 6 ], because we always gain access to all of the verices in a graph from vertex v1 (we always gain access to the floors of a building through the first floor) and we end our travel in a graph in vertex v6 (we cannot move further up from the floor 6).
        Now, we base our decisions about correspondance of vertices v2, v3, v4, v5 and floors on the fact that if v2 is some [ floor i] then all of the outgoing edges from v2 should point to higher floors. That is, once we are on the [ floor 4 ], the floors [ floor 1 ], [ floor 2 ], [ floor 3 ] become blocked for us — we cannot move to these floors from the current [ floor 4 ] by using outgoing edges of current vertex.

        At first we have some unordered set of vertices {1, 2, 3, 4, 5, 6}. Then we use topological sort to create an ordered set of vertices with the specified property (we cannot move down from higher floors). Formally, topological sort is a map:
        {1, 2, 3, 4, 5, 6} (1, 4, 2, 3, 5, 6).

        Below is a graphical representation of that mapping ( topological sort ).

        The distinctive property of the picture from the right is that all of the edges are looking to the right. None of the edges look to the left (backwards). Not a single child is pointing to a parent. That means, when you reach vertex v[i] as you go from left to right, there is no way you can update the state of v[i] later as you continue moving to the right.

        Actually, the graph on the right is an abstract representation of the concept of dynamic programming. We consider sequence of vertices 142356 in the specified order. When we are standing on the vertex v[i] it has optimal property (in our case time to travel to that vertex). We update from that vertex v[i] all of it's children. The next vertex in a sequence after v[i] now also has optimal property, because it was updated by parents which had optimal property themselves.

        All of that brings us to a conclusion that after we do topological sort we can just look into each of 10 edges (only once) in the following order:

        1. 1 → 4
        2. 1 → 2
        3. 4 → 2
        4. 4 → 3
        5. 2 → 3
        6. 2 → 5
        7. 2 → 6
        8. 3 → 5
        9. 3 → 6
        10. 5 → 6
        • »
          »
          »
          »
          »
          10 лет назад, скрыть # ^ |
          Rev. 4  
          Проголосовать: нравится 0 Проголосовать: не нравится

          We have 2 ways of reaching node 2 in your example:

          A: Via 3 nodes, cost 7
          B: Via 2 nodes, cost 3
          

          Why is it sufficient to process node 2 only once? We can't know yet whether route A or route B will be part of the final answer, so don't we have to accommodate both possibilities? Like this:

          1. 1 -> 4
          2. 1 -> 2
          3. 4 -> 2
          4. 4 -> 3
          5A. 2 -> 3
          5B. 2 -> 3
          6A. 2 -> 5
          6B. 2 -> 5
          7A. 2 -> 6
          7B. 2 -> 6
          8A. 3 -> 5
          8B. 3 -> 5
          ...etc...
          
          • »
            »
            »
            »
            »
            »
            10 лет назад, скрыть # ^ |
             
            Проголосовать: нравится 0 Проголосовать: не нравится

            Good question. Do not stop asking until you fully and completely understand.

            The node 2 is updated twice.

            The first time it was updated on the step 2: 1 → 2.
            During that step we updated our estimate of time to travel to that node from to 3. It is important to understand that the time 3 is the best time to travel from node 1. We cannot get better than that.

            The second time we try to update it again on the step 3: 4 → 2. This time we will not update our estimate with number 5 + 2 = 7, because the previous update was better. But again, the time 7 is the best time to travel from node 4. We can only improve that number if we reduce the time to travel to node 4. But we cannot reduce that time, because there are no backward edges pointing to node 4 and we have already explored all of the edged coming inside node 4 and updated it's state.

            The general pattern here is following. We only use edge uv if we are 100% sure about the optimality of vertex u. That is, we have to consider all of the edges coming into u before we start looking at the edges coming out of the node u.

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

              Thanks for your help. Your illustration of topological sorting is very nice. However, I don't think your solution works. "The second time we try to update it again on the step 3: 4 → 2. This time we will not update our estimate with number 5 + 2 = 7, because the previous update was better." If I understood you correctly, you mean we would forget about the 7 cost path because the path with cost 4 is cheaper? It's not correct. For example, if T=1000, then the optimal path will visit all 6 nodes (including the 7 cost path 1->4->2).

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

                I was asnwering your question regarding the complexity O(n2 × m).

                That is, I showed how we can find the shortest path in a Directed Acyclic Graph with complexity O(n + m) (which is better than O(n × m)). We managed to reduce the complexity by doing topological sort.

                We can use the same strategy in the original problem to reduce the complexity from O(n2 × m) to O(n2 + m).
                There is one more idea remaining on top of what I have already described.

                Let's concentrate on some vertex v[i]. There is a set of different paths from vertex v[1] leading to v[i].

                Now, as it is drawn in the picture, we split the set of all possible Paths from vertex v[1] to vertex v[i] into groups (disjoint subsets).
                Within each of those groups we will be performing comparison of travel times of those paths and look for a path with a minimum travel time. I've circled the minimum cost path in a group with red.

                In the worst case there are 5000 different path lengths (not paths!) from v[1] to v[i], because the maximum number of vertices in a graph is 5000 and we cannot make a path with repeating vertices.

                So, for each vertex we will be storing an array of minimum cost paths to that vertex:

                int minCost[5000][5000];
                

                The number minCost[i][5] stores the minimum time to travel from v[1] to vertex v[i]. But it is not NOT among all the possible paths, it is only among the paths in the group 5 (paths of length 5).

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

                  Nicely illustrated again, but I feel like you are describing my slow solution:

                  for each node in topological order:
                      for each v in minCost[node][v]:
                          for each outoing edge in node:
                  
                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  10 лет назад, скрыть # ^ |
                  Rev. 2  
                  Проголосовать: нравится +5 Проголосовать: не нравится

                  Ok, you've sowed a seed of doubt =)

                  I wanted to solve this problem after a week or two (when I forget the problem and the solution), but here we go...

                  The solution that I described: 21115101

                  Feel free to ask any questions about the code.

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

                  I can see your solution passed in 93ms, but I can't figure out how. You even have those 3 nested loops:

                  while (!sortedVertices.empty())
                    for (childV : g[curV])
                      for pathLength = 0 -> n-1
                  

                  The outer-most loop is 5000 worst case. The middle loop is 5000 worst case. The inner loop is 5000 worst case. How does this not lead to 5000^3?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  10 лет назад, скрыть # ^ |
                  Rev. 3  
                  Проголосовать: нравится +5 Проголосовать: не нравится
                  • The string of code
                  while (!sortedVertices.empty())
                  

                  gives us the complexity O(n).


                  • The following string of code
                  for (int pathLength = 0; pathLength < n - 1; pathLength++)
                  

                  increases our complexity to O(n2).


                  • And this string of code
                  for (auto childV : g[curV])
                  

                  does not multiply the complexity O(n2) to make O(n2 × m). This loop adds to the outer loop (which gives O(n + m)) and multiplies inner-most loop (which gives O(n × m)).

                  If we combine them, we get the complexity O((n + m) × n) = O(n2 + n × m).


                  Edit:

                  No, I am wrong. The following lines (both of them together)

                  while (!sortedVertices.empty())
                     for (auto childV : g[curV])
                  

                  give us complexity O(m) — we touch each edge only once.

                  When we add inner-most loop we get total complexity of order O(n × m).

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

                  Thanks! Now that you put it like that, it's obvious the complexity is O(n x m). Problem now is I have the same 3 nested loops in my solution, and with a ton of optimizations that code is still running for 3000ms. You probably don't want to scour through this, but I'll link it for reference in any case:

                  http://mirror.codeforces.com/contest/721/submission/21047724

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

                  Insert the counter in your code and calculate how many loops the code does.

                  The worst time is achieved on case #59. It starts with these 3 numbers:
                  3615 4935 245435090

                  So, you need to print the amount of loops when you encounter that case:

                  if (n == 3615 && m == 4935 && maxTotalCost == 245435090)
                  {
                    io.print(performanceCounter);
                    return 0;
                  }
                  

                  Your code will fail and you will see in the result how many times the inner-most loop was executed.


                  Here is my result: 21118607

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

                  Your code made 17M iterations, mine did 3M. And yours is 30x faster somehow.

                  http://mirror.codeforces.com/contest/721/submission/21168815

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

                  That means the problem is not in the algorithm.
                  The problem is either in the data structures (probably, collisions in HashMap) or in the input. I doubt that input is bottleneck, because in its maximum it is just about 1500 numbers.

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

                  Weird thing is I'm only putting longs and integers into the maps and there is a Java solution to this problem which also uses HashMaps and runs in 200ms.

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

                  Look at the cases #8, #9, #10. They both have the maximum possible input and your solution works in 150 ms!

                  But something interesting happens in the case #12. It is not the hugest input. Just 1686 vertices and 4331 edges, but it makes your solution go over 1 second.


                  On the case #10 the program does only 29611 operations and it takes 140ms to perform them.
                  The case #12 takes 2237322 operations and the times blows up to 1076ms.

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

                  Look at this: 21172009

                  17835090 operations and only 265ms!

                  The only difference I see is that there are no HashMaps and no TreeMaps.

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

                  Thanks for your help. There are HashMap-based solutions which perform in 200ms, so it's still unclear to me what exactly makes my solution slow, but I feel like it may not be worth pursuing further.

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

      Pixar,

      I have done step 2 of your solution using recursion. Can you please explain why step 1 (topological sort) is necessary?

      Basically, I define a recursive DFS (vertex1, N, time) which stores number of vertices covered and time taken; and call DFS(1,n,T).

      My code — CODE gives TLE on test case 11, although I guess DFS algorithm in itself is not exponential time?

      Any idea why this might be happening?

      Thanks in advance.

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

        We need to know the order in which to process the sequence of vertices. Searching for the right order is called sorting.

        Now, what is right order? For us the right order is the situation when we finish processing children of vertex v[i], the next vertex in our order v[i + 1] has the cost (time to travel) which cannot be improved.

        What does it mean to improve the cost of the vertex? That means we have found some parent vertex from which we can reach the current vertex by using a smaller cost.
        Well, the whole algorithm is a continuous reevaluation of our estimates of the times to travel to each vertex. After each evaluation we reduce our estimates. At first we say that each vertex in a graph has very big cost. On each pass of our algorithm we do these reevaluations of the costs. We reduce and reduce until our estimate becomes the real minimum cost.

        How many times should reevaluation of the estimate cost happen?
        Let's take some vertex vk. For example, it has 3 parent vertices: v1, v2, v3. Then we will do the reevaluation of the cost only 3 times!
        On some step of our algorithm we become sure that we cannot improve the estimate of the cost to travel to v1. At that moment, we update estimate of child vertex vk.
        On some other step of the algorithm we become sure in the estimate of v2. Then we do the second update of the state of the vertex vk.
        And situation repeats for the vertex v3.

        If we have processed all of the parents v1, v2, v3 of the vertex vk, there is no way we could ever improve the estimate of the vertex vk! Why? Because there are no more vertices left which lead to vk and we can only improve the estimate of the cost of vk from vertices leading to vk. What does this mean for vk? It means that vk itself became optimal and we can update the estimates of the children of vk.


        • I don't think it is possible to solve this problem using DFS.
        • The complexity of DFS is O(n + m).

        I was wrong regarding the impossibility to solve it with DFS. Here is the solution with DFS.

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

I just hope 2d dimensional dp for both path parent and cost in Div2C doesn't give memory limit exceed on Div2C. It was pretty close on sample tests :|

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

Did someone experience problem with lack of memory in Div2C?
This is the first time it happened to me.

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

I would have had a successful hack if the contest had 5 more seconds :(.I have already written and copied the hacking input when the time was out.

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

DIV2B pretests are too weak. my wrong solution where i didnt increment time by 5 sec when k strings are matched passed pretests . hell . hoping my final solution passes

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

I was surprised that so many people solved C

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

Pretests in div2 B are weak because i didnt increment time by 5 sec due to typo error still pretests passed. hope my final solution passes

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

what's an unexpected verdict?

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

I wonder if this solution for Div2E is correct... I finished the debugging minutes after the contest and I have no idea if it would fail on test case 12 again.

http://pastebin.com/AJ7HrMF6

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

Hhmmm...

seems odd

dkjsfkhg accepted C and D at 1:58 and 1:59.

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

could anyone explain why the following code fails (TLE)? 21035958

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

In the last three contest Div 2C is a DP problem...

Seems like its time to start practicing DP

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

I really liked the problemset. Solved D, but submitted 1-2 seconds after the contest ended. It would've been the first D I solved on a contest. Anyways, I hope everyone did well and more importantly had fun. Now just to wait for system testing :)

Also, what was the idea behind C, DFS got TLE. Seems like it's DP but I can't think of a formula.

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

PTs for Div.2B are really weak.I was so foolish that I locked it before making hack data.Then i found that i can hack myself...

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

I feel so frustrated again because of not solving the C problem. During the contest, I did not have any thought about DP, I used only DFS...

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

Когда читаешь задачу B, а именно строчку:"Ваня не будет вводить один и тот же пароль несколько раз." Кажется, что в тестах может быть случай, когда существует несколько ОДИНАКОВЫХ паролей. Однако же попытки взлома с таким условием дали "некорректный тест" [FAIL All passwords must be distinct], Что говорит о том, что все пароли должны быть уникальны. И судя по решениям участников не так мало людей согласны со мной в понимании условий этой задачи.

Сказать то хочется только одно по этому случаю: Не надо так)))

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

    Иногда, когда я не понимаю условие после прочтения на русском, я использую такой трюк: я открываю описание задачи на английском =)

    После прочтения условия задачи в первый раз у меня тоже возник такой вопрос, но, открыв английскую версию, всё сразу встало на места. Там есть вот такая чёткая фраза: " pairwise distinct non-empty strings".

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

My B solution got hacked, What would be the problem with that code? http://mirror.codeforces.com/contest/721/submission/21032401

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

Expecting lots of hacks(System testing failure) on 2nd question. No pretest to bound best part of question passwords

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

hacking test case of B is very interesting, but not many people see it, so we don't see hack war :D(like 373)

PS : I will get WA on B because that. That is so sad

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

How would O(N^2logN) gets TLE in 3 sec, problem C -_-

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

I see about 1100 people passed pretest on C but about 600 accepted, why ??

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

http://mirror.codeforces.com/contest/721/submission/21030275 Memory Limit exceeded in 33 test case ... :| I saw some solutions with similiar limits ... unfair !

»
10 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится -13 Проголосовать: не нравится

wrote a generalised soln for div 2 C ( maximum nodes which can be covered starting from 1 ) until after contest when i read the output statement of question ( path has to end at n ) !

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

This code gives me the correct answer in my computer. But it is wrong in their machine.

Can anyone tell me what is the reason behind this??

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

I received a really strange Runtime Error on problem B and am not able to identify the reason.

What is wrong here? 21044715

I suspect the error is on the first sort after playing with the answers that Codeforces give me.

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

Is something is wrong with the ratings? I think all three should be "Became Candidate Master"

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

Wonder! I noticed the solving time of problem a of rank 1 holder in standing(he is from div1). How is it possible to read problem description and write such long code only within 1 minute !! His code

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

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

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

Why this code gives http://mirror.codeforces.com/contest/721/submission/21026545 gives runtime error while http://mirror.codeforces.com/contest/721/submission/21044409 gives accepted. The only difference between the two codes is that i am using comparator function for sorting the strings in non-decreasing order of length in 1st code

comparator function

Can someone help what is the problem when i am using the above comparator function and thus causing the runtime error ?

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

In problem C, I took the maximum number as 10^9 and got Runtime error case 66, Now submitted the same code with value 10^9+1. Got Accepted. Why am I so stupid ? -_-

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

I got Skipped, can you tell me why ?

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

kudos to the author for the awesome contest, where even 4th question was well in reach! looking forward to more rounds from your side @vovuh

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

Hello , Can someone solve some of my doubts!
My solution 21045986 passes even though the first line of my loop( while(K--) ) has a pair < int , int > which can obviously overflow(first element is the element of the array) and I resubmitted it after changing it to pair < long long , int > and got AC. But to my surprise this submission also gets AC(I don't get why ) . Can someone explain?

Moreover is there some compiler flag which I can use to warn me whenever I try to typecast a data type to other which can cause data loss?

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

66 test cases of a problem and the one your code gets WA on, 66

Life is hard

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

why so serious to down vote my comments !?

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

Can you guys help me with some debugging tips?

  1. How do you efficiently debug big codes?
  2. How do you quickly find out which part of the code has the problem?
»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone explain C? I got ACC with a 3000ms solution but I can see many people with <200ms solutions. I process nodes in topological order and maintain dp[i][j] (or map for the same purpose due to memory constraints) where dp[i][j] = minimum cost to reach vertex i through j vertices. What am I missing here?

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

Concerning problem C, "output any solution" means I can choose any solution ? I can't pass because sometimes my path differs from the judge but it is correct :/

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

Publishing editorials after such long delay kills excitement. BTW, why can't editorials published just after contest ends? Any alternate solutions discovered during contest can be added to editorials later..

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

can someone tell me whats wrong with my D solution? http://mirror.codeforces.com/contest/721/submission/21054178

here i consider 0 to be positive first, if the number of negative numbers is even, i find the number with the lowest abs value, keep reducing its abs value untill its sign is changed.

then while we still have operations left, find the number with the smallest abs value, and increase its abs value.

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

I'm looking forward to the solution... The problem E was a little bit hard for me. :D

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

I have no idea why did my code failed on test case 50... Can anyone help point it out?

http://mirror.codeforces.com/contest/721/submission/21056370

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

.

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

Were I in problem E, I would probably sing when there weren't light because I would be frightened by the dark and sing to encourage myself.

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

Can anyone explain why 21030683 receives runtime error, but 21056614 passes? All i did was add a random comment at the beginning. Also if i send exactly the same code that got RE with C++14 it passes without any comment magic.

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

I'm wondering how author can check solution of D correct or not? Is it necessary to calculate product of all elements by using prime accumulation?

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

Im wondering how author can check D's solutions correct or not? Is it necessary to calculate product of array by using prime accumulation? Ps: I accidentally posted in Russian version, so I must re-post :((

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

where is the editorial??

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

Hey guys,

Thank you for the contest, but the problem statements really pissed me off during the contest:

Problem B:

Vanya is managed to enter his favourite site Codehorses.

What does that even mean? He wants to enter the web-site? He has managed to enter? He wants to sign in?

Vanya uses n distinct passwords for sites at all in total.

Vanya will enter passwords in order of non-decreasing their lengths

Just when Vanya will have entered enters the correct password, he is immediately authorized on to the site

But if Vanya will enter wrong password k times in a row, then he is able allowed to make the next try only 5 seconds after that

Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that he enters a password as soon as he is able to do so

Also I missed the sentence about the fact that the input contains the actual password of Vanya, because it was only mentioned in a sentence inside the Input part of the problem statement. Although I should probably pick on myself for that, authors should have mentioned that in the problem description. I believe that the Input and Output parts should only describe the format of the input and output, NOT add any meaning or logic to the problem.

Problem D:

he invented positive integer x

Wait, what? Do we still invent numbers these days? He came up with a number, he found a number, but certainly he didn't invent a number.

Maxim is a curious minimalis minimalist

Is that a joke or a pun? Because minimalism doesn't really refer to a desire to minimize numbers in an array.

thus he wants to know what is the minimum value that the product of all array elements (i.e. ) can reach, if Maxim would apply no more than k operations to it :

thus -- people around don't really say "thus", they say "so", unless they are coming from the 18th century.

Here's what I think would make this sentence clearer and correct: So he wants to know what the minimum value of the product of all elements of the array would be, if he applies no more than k operations to that array

And this is not everything that could be improved to make problems clearer. I am nitpicking, but it is something that makes thing much harder to understand if done in almost every sentence. We all want to make Codeforces better, and all what I mean by this comment is that there are certainly ways to do that just by spending few minutes to review the problem statements before the contest. Otherwise, every time I read it in English, it turns into a hell of figuring out what the author meant.

I hope other people feel the same way too.

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

FreeEditorial

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

Test case 7 of E-Road To Home doesn't seem to satisfy the conditions of the question. Can Danil start singing at x=12 which is the end? If no, I am getting output of 4,but 5 is the answer. Can someone explains me this thing. Thank you.

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

where is editorial?

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

editorials please??

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

Excelent set of problems but with a missing editerial. :(

By the way, I think problem D is full of details which causes a mass of code with mountains of special cases. Anyone think it's good for a Codeforces problem or bad?

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

WHERE IS TH EDITORIAL???

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

when is 'soon'?????? :(

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

Editorial pls

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

Can anyone give detailed solution for problem C,Div 2

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

    And different ways to solve this problem please. I understood the way using dp as suggested by Pixar using dfs and dp using pathLength. What are other ways to solve problem. Full discription please.