Tracing (Laser) Pointers

시간 제한2초메모리 제한2048 MB

요약
각 레이저 포인터는 주어진 기울기의 반직선 위에 있다. x축과 만나는 반직선들의 교점 x좌표를 기준으로 이름을 정렬해 출력한다.
난이도

보통10점 중 4점

유형
기하, 정렬, 수학
정답자
아직 제출이 없습니다

문제

Can you help me? There are pointers pointing everywhere! I’ve spilled all my laser pointers onto a 2D plane. Even worse, they’re all still turned on! At least this gives us a fun order in which to pick them up! I’d prefer if we grabbed all my pointers in ascending order of where their laser beam contacts the xx-axis. If their laser doesn’t shine across the xx-axis, then it’s not worth grabbing, and do not include it in the list. It belongs on the ground!

Each laser pointer has a name, and I’ll make sure to give you where the laser pointer is, as well as the slope of the line of the direction in which it’s pointing. I’ve never bought the same laser pointer twice, so the names are all unique. Just give me the list of names in the right order, and I’ll pick them up!

Don’t worry, we got lucky, and all laser pointers are pointing towards positive infinity on the xx-axis, and they’re all at least 11 away from the xx-axis. I did a quick scan of all the pointers, and if a laser pointer was ever going to shine on the xx-axis, then it’ll do it by at most x=100000000x=100000000. Also, the gap between where two different laser pointers hit the xx-axis is always at least 0.000010.00001. Whew! Imagine how annoying it would have been otherwise!

Figure 1: Illustration of the 3rd sample input and output. Lasers B,C,A,E intersect the xx-axis in that order. Laser E does not intersect the xx-axis.

입력

The first line of input contains an integer NN (1≤N≤1051≤N≤10^5). Then NN lines follow, each containing three real numbers xx, yy, mm, with 0≤∣x∣≤100000≤|x|≤10000, 1≤∣y∣≤100001≤|y|≤10000, and 0≤∣m∣≤100000≤|m|≤10000 and then the name of the laser pointer. Here, (x,y)(x,y) indicates the coordinates of the origin of the laser pointer, and mm indicates the slope. All real numbers are given with exactly 66 digits of precision after the decimal. Each name is alphanumeric, contains no whitespace, is non-empty, and has at most 100100 characters. At least one laser pointer is pointing towards the xx-axis.

출력

Return the list of names of laser pointers that hit the xx-axis, in ascending order of where they hit the xx-axis. Each name should be on a separate line, with no leading or trailing spaces.

예제3

  1. 예제 1

    입력
    2
    1.000000 3.000000 -0.500000 UberPointerX3000
    2.000000 -4.000000 2.000000 SigmaLaserMarkIIOopsWeMeantMark2
    
    예상 출력
    SigmaLaserMarkIIOopsWeMeantMark2
    UberPointerX3000
    
  2. 예제 2

    입력
    3
    -1.000000 5.000000 -5.000000 LegendaryPremiumUltraSuperLaser
    -2.000000 10.000000 -1.000000 LongRangeDeluxeClassyLaser
    -3.000000 15.000000 1.000000 HonestlyJustABoringAndCheapLaserPointerNotReallyWorthPickingUp
    
    예상 출력
    LegendaryPremiumUltraSuperLaser
    LongRangeDeluxeClassyLaser
    
  3. 예제 3

    입력
    5
    2.000000 6.000000 -0.600000 A
    3.000000 -4.000000 3.000000 B
    11.000000 -1.000000 2.000000 C
    7.000000 9.000000 0.100000 D
    15.000000 8.000000 -4.500000 E
    
    예상 출력
    B
    C
    A
    E