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

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

I am new in geometry.I am trying to solve some basic problem about geometry.Hence i found a nice problem http://lightoj.com/volume_showproblem.php?problem=1058 . But I have no idea about this types of problem. If anyone can help with some idea by how i solve this problem, i will be so much benefited. Please help me. Thanks in advance. :)

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

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

This problem is about counting equal vectors. If you code in C++ you can use the map container to count them.

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

    I understand your idea Anuar a little bit.Will you explain it ? I am code in c++.

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

      I will try to explain it. First you should compute the equation of each line. In my opinion you should have two map containers map1 and map2. In the first one you should store the A and B coefficients and the second one — A, B anc C. Then just loop over the equations and add map1(A,B)-map2(A,B,C) to the answer. The total complexity is O(N^2 * log(N^2)).

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

        After 40 minutes, 10 submissions and lots of frustration later, I finally got AC on a problem I underestimated. The solution I coded at first got MLE, then TLE after optimisations. I'm not so sure your solution with two maps will suffice, as my initial solution with one map already got MLE. Not only did I have to use unordered_map to save memory and time, but I also had to use the fact that there are no 4 collinear points (so it is sufficient to subtract any occurences of three points equidistant and collinear which can be done using an unordered_set.)

        TL;DR — definitely underestimated how challenging time/memory limit could make it.

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

This problem is also on Codeforces. Link: http://codeforces.me/contest/660/problem/D