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

Автор Rupai, 15 лет назад, По-английски
My problem statement:

You are given N (N<=1000) points in X,Y co-ordinates. X and Y are both positive. Now, the problem is using maximum number of point you have to draw a straight line and also using maximum number of point you have to draw a 1/4 shape parabola. Actually, here you have to solve two problem at the same time. You can use any point to draw any one from those. You can use those point that are use to draw a straight line for 1/4 shape parabola.

Now all I need is your help to solve this problem. Please discuss your opinion.
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

15 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
For the first problem. Choose a point A, then sort all other points Pi by an angle formed by a line APi and coordinate axes. Then you can test all lines going through A and including at least two of points of the entire given set in linear time, and a whole time complexity for this part of a problem is O(N2logN).
But what is a "1/4 shape" parabola?
  • 15 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +5 Проголосовать: не нравится
    Actually 1/4 shape parabola means this type of shape I try to draw here.
                             .
                         .
                      .
                   .
                .
             .
           .
          .
         .
        .
       .
      .
     . 
    .
    .
    • 15 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +3 Проголосовать: не нравится
      I didn't get it. Surely, there is a definition of this term in the problem statement. Just retell it.
      • 15 лет назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится
        Actually this problem is mine. It's not from any site. Would you please visit this site http://en.wikipedia.org/wiki/Parabola. Here the first picture is "A parabola". In my problem I don't want to draw the full parabola, I want just half of it. If you divide the picture in the middle then you find the shape that is I try to drawn in the above. Thank you for your reply. The solution of first part really help me.
        • 15 лет назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится
          Not at all, the first part is a very typical geometrical problem. But for the second part I can suggest only an O(N3logN) solution by analogy: fix two points, then sort other by something like an "angle in parabolical coordinates", i.e. by some coefficient in an equation of a parabola which is going to be drawn through the three. But if N is about 1000, it should be rather slow, of course.
  • 15 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    I think, parabolic part can be solved in a similar way. First fix one point. Now for each second point you can "draw" a parabola or a line through them. Now you have a multiset of parabolas/lines and need to find the the one with the most occurences in it. Of such answers for each ("fixed") point choose maximal. O(N^2logN) complexity. Well, I assume the parabola has a form f(x)=(x-a)^2+b, i.e. has fixed x^2 coefficient.
    • 15 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +8 Проголосовать: не нравится
      Yeah, it seems that we can generalize this method to drawing any curve, and its time complexity should be O(NklogN), where k is a number of independent parameters in an equation of a curve :)
15 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится
we can use hash table to solve first problem with O(n^2), we don't need to sort points by angle, we can divide both coordinates by their gcd and add to hash table. and for second problem we also can use hash table to improve our solution in log(N) times
15 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
кстати, какого фига вы пишете в русском интерфейсе? уже 8 постов написали на своем ломаном английском.