#P2772. 寻找平面上的极大点

寻找平面上的极大点

Description

On a plane, for two points (x,y)(x,y) and (a,b)(a,b), we say that (x,y)(x,y) dominates (a,b)(a,b) if xax\ge a and yby\ge b.

Geometrically, this means that (a,b)(a,b) lies in the unbounded region whose upper-right corner is (x,y)(x,y).

Given a set of nn points, there exist some points that are not dominated by any other point in the set; these points are called maximal points.

Write a program to find all maximal points and output their coordinates in increasing order of the xx-coordinate.

Input Format

The input consists of two lines. The first line is a positive integer nn, the number of points. The second line contains nn points’ coordinates. All coordinates are integers. No two points in the input share the same coordinates.

Output Format

Output all maximal points in increasing order of the xx-coordinate.

The output format is: (x1,y1),(x2,y2),,(xk,yk)(x1,y1),(x2,y2),\cdots,(xk,yk).

Note: Each point is separated by ,, and there is no , after the last point. Missing or extra output will be judged incorrect.

5 
1 2 2 2 3 1 2 3 1 4
(1,4),(2,3),(3,1)

Hint

For 50%50\% of the testdata: 1n1001\le n\le 100; 0x,y1050\le x,y\le 10^5.

For 100%100\% of the testdata: 1n5×1051\le n\le 5\times 10^5; 0x,y1050\le x,y\le 10^5.

Translated by ChatGPT 5