Under construction

Still being built. Things may change

Fence

Time limit2sMemory limit1024 MB

Summary
Given a convex polygon and one interior post, find a maximum-area polygon whose vertices are these posts, with no other post strictly inside it.
Level

Hard8 of 10

Topics
Geometry, Dynamic programming
Solved
No attempts yet

Problem

The fence around Princeton-Plainsboro Hospital was built long before Dr. House, Dr. Cuddy, and the rest of the current staff arrived. The fence is a convex polygon. Posts stand at its vertices, and its edges are fence sections. By mistake, an extra post was built inside the fence, that is, on hospital grounds, and it has caused the staff and patients a lot of trouble.

Dr. Cuddy wants to fix this by building a new fence around the hospital. The new fence must satisfy three conditions:

  • The vertices of the new fence polygon can only be existing posts (the vertices of the old fence and the one post inside it).
  • No post that is not a vertex of the new polygon may lie inside it.
  • Its area must be as large as possible.

The new fence polygon may be non-convex, and some posts outside its area may stay unused.

Input

The first line contains one integer nn (3≤n≤1053 \le n \le 10^5), the number of vertices of the old fence polygon. Each of the next nn lines contains two integers xx and yy, with absolute values not exceeding 10810^8, the coordinates of a vertex. The coordinates are given in counterclockwise order, and the polygon is convex. No three vertices lie on one line.

The last line contains two integers XX and YY, with absolute values not exceeding 10810^8, the coordinates of the extra post. It is guaranteed that the point (X,Y)(X, Y) lies strictly inside the polygon.

Output

Print the polygon of the new fence in the same format as the old one: the number of vertices on the first line, followed by the coordinates of each vertex on its own line. No post that is not a vertex may lie strictly inside the new fence, and its area must be maximal.

Examples1

  1. Example 1

    Input
    4
    -1 -1
    1 -1
    1 1
    -1 1
    0 0
    
    Expected output
    5
    -1 -1
    0 0
    -1 1
    1 1
    1 -1