POJ C Programming Advanced Programming Question # #: Finding the greatest point on a plane

Source: Internet
Author: User

Programming Question # # #: Finding the greatest point on a plane

Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )

Note: Total time limit: 1000ms memory limit: 65536kB

Describe

In a plane, if there are two points (x, y), (A, B), if (x, y) is dominant (a, B), this refers to the x>=a,y>=b;

Graphically, A (a, b) is located in an infinite area (x, y) in the upper right corner.

Given the set of n points, there must be a number of points that are not dictated by any point in the collection, which are called maxima points.

Programming to find all the great points, according to the x-coordinate from small to large, the output of the maximum point coordinates.

The subject: N not more than 100, and do not consider the point of the coordinates of a negative case.

Input

The input consists of two lines, the first line is a positive integer n, the second row contains the coordinates of n points, the coordinate values are integers, the coordinates range from 0 to 100, and no points in the input data have the same coordinates.

Output

Outputs all the maximum points in the order of the x-axis coordinates to the smallest size.

The output format is: (X1,y1), (x2,y2),... (Xk,yk)

Note: There are "," dividers between each point of the output, and no "," after the last point, with fewer outputs and multiple outputs, which will be misjudged

Sample input
51 2 2 2 3 1 2 3 1 4
Sample output
(1,4), (2,3), (3,1)
Tips
1#include <stdio.h>2#include <iostream>3 using namespacestd;4 5 intMain ()6 {7     intN, L =0;8Cin>>N;9     inta[101][2], b[101][2];Ten      for(inti =0; I < n; ++i) One     { Acin>>a[i][0]>>a[i][1]; -     } -      for(inti =0; I < n; ++i) the     { -         BOOLBadpoint =false; -          for(intj =0; J < N; ++j) -         { +             if(a[i][0]<=a[j][0] && a[i][1]<=a[j][1] && i!=j) -             { +Badpoint =true; A                  Break; at             } -         } -         if(!badpoint) -         { -b[l][0] = a[i][0]; -b[l][1] = a[i][1]; inl++; -         } to     } +      for(inti =1; I < L; ++i) -     { the          for(intj =0; J < I; ++j) *         { $             if(b[j][0]>b[i][0] || (b[j][0] = = b[i][0] && b[j][1]>b[i][1]))Panax Notoginseng             { -                 inttemp[2]; thetemp[0] = b[j][0]; +temp[1] = b[j][1]; Ab[j][0] = b[i][0]; theb[j][1] = b[i][1]; +b[i][0] = temp[0]; -b[i][1] = temp[1]; $             } $         } -     } -      for(inti =0; I < L-1; ++i) the     { -printf"(%d,%d),", b[i][0], b[i][1]);Wuyi     } theprintf"(%d,%d)", B[l-1][0], B[l-1][1]); -     return 0; Wu}

POJ C Programming Advanced Programming Question # #: Finding the greatest point on a plane

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.