[JSOI2008] [Valley P1227] Perfect symmetry

Source: Internet
Author: User

Title Description DescriptionDuring the summit, a number of bodyguards must be used to defend the representatives of the countries attending the Conference. In addition to being protected by his own personal bodyguard, the organizers also assigned some other agents and snipers to protect them. In order to make their work fruitful, the security of the person being defended is ensured as far as possible, and the bodyguards are assigned to the various directions of the protector.
The Bodyguard's best standing position should be this: the Protector should stand in the symmetry center of all bodyguards. However, as long as the insured
When the guards move, it is difficult for the bodyguard to adjust the position according to the new position of the VIPs. It's hard for most agents to make real-time adjustments.

Therefore, the security Minister decided to reverse the process, the bodyguards first stand in their place, and then people in their symmetry center to find a suitable position. If you want to walk around, we are not responsible for his safety.

Your job is to make this process automatic. Give a set of n points (bodyguards position), you want to find their symmetry center s, where the protector will be relatively safe. below and so on.

First we give a point a and a symmetry center s, point A ' is a point a in S is the symmetry center of the image point, that is, point S is the line of AA ' symmetry center.
The lattice group (X) is an S-centered image point that consists of a lattice group of pixels of each point. X is used to produce the symmetry center s, that is, the set of dot-matrix X s-centered image points is the lattice x itself.
input/output format input/output Input Format:
The first line of the input file is an integer n,1<=n<=20000, and the next N rows contain two integers, Xi and yi,-100000<=xi,yi<=100000, separated by spaces, representing the Cartesian coordinate values of the first point in the set of dots.

Because no two bodyguards are in the same position, any two points are different in a given job. But be aware that bodyguards can stand in the same position as the protector.
output Format:
The output file has only one row.  If a given lattice can produce a symmetric center, the output is "V.I.P." Should stay at (x, y). ", where x and y represent the Cartesian coordinate values of the center, the format is rounded to one digit after the decimal point.

If the group has no symmetry center, output "This is a dangerous situation!", pay attention to the output, in addition to two words separated by a space, do not output extra space. input and Output sample sample Input/output sample Test point # # Input Sample:

8
1 10
3 6
6 8
6 2
3-4
1 0
-2-2
-2 4

Sample output:

V.I.P. Should stay at (2.0,3.0).

Analysis: First to sort, the horizontal axis is the first keyword, the ordinate for the second keyword, from small to large sort. To ensure that the bottom left corner is at the top and the top right corner is at the end. The two points must be a pair of central symmetrical points. You can therefore draw a central symmetry point, which is the midpoint of the first point and the last point after sorting. Then the a[i] and the a[n-i+1] ear of the transverse ordinate test can be respectively.

#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespacestd; intx[20001],y[20001],n; DoubleXx,yy; intRead () {CharC=GetChar (); intA=0; BOOLflag=false;  while((c<'0'|| C>'9') &&c!='-') c=GetChar (); if(c=='-') {flag=true; C=GetChar (); }       while(c>='0'&&c<='9') {a=a*Ten+c-'0'; C=GetChar (); }      if(flag)return-A;Else returnA; }  voidSwapintIintj) {intT; T=x[i]; X[I]=X[J]; x[j]=T; T=y[i]; Y[I]=Y[J]; y[j]=T; }  voidQuicksortintHeadinttail) {       intI=head,j=tail,mid= (I+J)/2;  while(i<j) { while(x[i]<x[mid]| | X[i]==x[mid]&&y[i]<y[mid]) i++;  while(x[j]>x[mid]| | X[j]==x[mid]&&y[j]>y[mid]) j--; if(i<=j) {swap (I,J); I++; J--; }       }       if(head<j) quicksort (HEAD,J); if(i<tail) quicksort (i,tail); }  intMain () {n=read ();  for(intI=1; i<=n;i++) {X[i]=read (); Y[i]=read (); } quicksort (1, N); XX=((Double) (x[1]+x[n])/2); YY=((Double) (y[1]+y[n])/2);  for(intI=2; i<=n/2+1; i++)          if((Double) ((x[i]+x[n-i+1]! = (xx*2))|| (Double) (y[i]+y[n-i+1]! = (yy*2) {printf ("This is a dangerous situation!"); Exit (0); } printf ("V.I.P. Should stay at (%.1LF,%.1LF). \ n", Xx,yy); return 0; }
PS: Title Description More space, cause i wa several times, pit Ah!

[JSOI2008] [Valley P1227] Perfect symmetry

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.