Under construction

Still being built. Things may change

LaLa and Monster Hunting (Part 1)

Time limit5sMemory limit1024 MB

Summary
Given N circles with integer centers and radii, determine whether the convex hull of the circles contains the origin.
Level

Medium7 of 10

Topics
Geometry, Sorting
Solved
No attempts yet

Problem

A dreadful monster has been spotted in a forest near the city of magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} Sharia. A group of valorous adventurers will hunt it down within a few days, before it hurts anyone. However, LaLa\color{blue}{\text{LaLa}} knows the real reason those adventurers are willing to take the risk. The monster is known to produce a rare magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stone in its intestines, and the stone is quite beautiful. LaLa\color{blue}{\text{LaLa}} wants to obtain the magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} stone before the adventurers do.

LaLa\color{blue}{\text{LaLa}} will first locate the monster with her magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}}. LaLa\color{blue}{\text{LaLa}} has placed several magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} tools in the forest, and each tool has a power.

Draw a circle centered at each magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} tool, with radius equal to its power. LaLa\color{blue}{\text{LaLa}}'s magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} locates the monster if and only if the convex hull of the circles contains the monster's location. Write a program that determines whether LaLa\color{blue}{\text{LaLa}} will be able to locate the monster.

Input

The input is given in the following format:

NN

x_0x\_0 y_0y\_0 r_0r\_0

x_1x\_1 y_1y\_1 r_1r\_1

⋮\vdots

x_N−1x\_{N-1} y_N−1y\_{N-1} r_N−1r\_{N-1}

NN is the number of magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} tools in the forest. The ii-th tool is located at (x_i,y_i)(x\_i, y\_i) and has power r_ir\_i. The monster is at (0,0)(0, 0).

The input satisfies the following constraints:

  • All the numbers in the input are integers.
  • 1≤N≤1,000,0001 \le N \le 1\\,000\\,000
  • −1,000,000≤x_i,y_i≤1,000,000-1\\,000\\,000 \le x\_i, y\_i \le 1\\,000\\,000 for all integers 0≤i<N0 \le i < N
  • 0≤r_i≤1,000,0000 \le r\_i \le 1\\,000\\,000 for all integers 0≤i<N0 \le i < N
  • The distance between point (0,0)(0, 0) and the boundary of the convex hull of NN circles, ii-th of which is centered at (x_i,y_i)(x\_i, y\_i) and has radius r_ir\_i, is at least 11.

Output

If LaLa\color{blue}{\text{LaLa}}'s magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} will successfully locate the monster, print 'Yes'. Otherwise, print 'No'. You may print each character in either case (lower or upper).

Hint

The figures below show the tool placements for the sample tests. The red curve is the boundary of the convex hull.

Test 1Test 2Test 3

Examples3

  1. Example 1

    Input
    3
    -3 0 1
    0 0 3
    3 0 1
    
    Expected output
    Yes
    
  2. Example 2

    Input
    3
    2 0 1
    0 2 1
    -5 -5 3
    
    Expected output
    Yes
    
  3. Example 3

    Input
    1
    3 3 1
    
    Expected output
    No