"Water" jsoi perfect symmetry

Source: Internet
Author: User

Perfect symmetry.

Title Description

During the summit, many bodyguards must be used to defend NATO's national representatives. 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 protector moves, 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.

So, the interior minister, Gauss decided to reverse the process, the bodyguards first stood in their place, and then wanted to find a suitable position in their symmetry center. 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

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

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 Xs and y represent the Cartesian coordinate values of the center, and the format is rounded to one digit after the decimal point. If the group has no symmetry center, output "This is a dangerous situation.", note that the output is separated from the two words by a space, do not output extra space.

Sample Example

Symmetry. Inch

8

1 10

3 6

6 8

6 2

3-4

1 0

-2-2

-2 4

Symmetry. Out

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

Ideas

Random yy in one order to read the data into the first and X, Y for the second key word sequence, and then the first and the last midpoint as the Datum, the other point to the midpoint if there are unequal output dangerous otherwise output datum

The sort has been tuned for a long time, without overloading the operators or using CMP (or I'm not writing overloaded operators)

Code
#include <iostream>#include<cstdlib>#include<cstdio>#include<cstring>#include<algorithm>using namespacestd;intN,i,j,tail;structnote{intx, y;}; Note s[200005];intps[ -];BOOLcmpConstNote A,ConstNote b) {    if(a.x>b.x)return true; if(a.x<b.x)return false; if(A.Y&GT;B.Y)return true; if(A.Y&LT;B.Y)return false; return true;}intMain () {Freopen ("symmetry.in","R", stdin); Freopen ("Symmetry.out","W", stdout); CIN>>N; BOOLPd=true;  for(i=1; i<=n;i++) {cin>>s[i].x>>S[i].y;} Sort (S+1, s+n+1, CMP); DoubleTx= ((Double) (s[1].x+s[n].x)/2); DoubleTy= ((Double) (s[1].Y+S[N].Y)/2); BOOLflag=true;  for(i=1; I<= (n>>1)+1; i++)    {        if((Double) ((s[i].x+s[n-i+1].x)! = (tx*2)) {flag=false; Break;} if((Double) ((s[i].y+s[n-i+1].Y)! = (ty*2)) {flag=false; Break;} }    if(flag==true) printf ("V.I.P. Should stay at (%.1LF,%.1LF).", Tx,ty); Elsecout<<"This is a dangerous situation!"<<Endl; System ("Pause"); return 0;}
Results

"Water" jsoi 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.