P1227 [JSOI2008] Perfect symmetry title description
During 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 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, formatted as 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 input example # #:
81 103 66 86 23-41 0-2-2-2 4
Sample # # of output:
V.I.P. Should stay at (2.0,3.0).
Description
[JSOI2008] Second round
The baby does not understand why the problem is the province of choice,
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>#defineN 20001using namespacestd;DoubleXx,yy;intN,sx,sy,x[n],y[n];intRead () {intx=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} while(ch>='0'&&ch<='9') x=x*Ten+ch-'0', ch=GetChar (); returnx*F;}intMain () {n=read (); for(intI=1; i<=n;i++) X[i]=read (), Y[i]=read (), sx+=x[i],sy+=Y[i]; XX=1.0*sx/n,yy=1.0*sy/N; printf ("V.I.P. Should stay at (%.1LF,%.1LF).", Xx,yy); return 0;}
64 points code (without considering the absence of symmetry center, I think it should have symmetry center)
We know that the center of symmetry must be the middle of a set of symmetric numbers, and if these numbers have a symmetric center, all the symmetry points are the same as the center of Symmetry, where the center of symmetry is the middle of the two number x, and y is the middle of the two number Y, which we can directly add and divide by the number of numbers, This is supposed to be the symmetry center, and then we're judging the symmetry centers in these points, not in this place.
A pair of symmetric points must be if the X of a point is small, then the other x must be large, so that we order, to see if the symmetry of the two-digit symmetry point is in this position
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>#defineN 20001using namespacestd;DoubleXx,yy;intN,sx,sy;intRead () {intx=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} while(ch>='0'&&ch<='9') x=x*Ten+ch-'0', ch=GetChar (); returnx*F;}structa{intx, y;} A[n];intCMP (A a,a b) {if(a.x!=b.x)returna.x<b.x; if(A.Y!=B.Y)returna.y<b.y;}intMain () {n=read (); for(intI=1; i<=n;i++) a[i].x=read (), A[i].y=read (), sx+=a[i].x,sy+=a[i].y; XX=1.0*sx/n,yy=1.0*sy/N; Sort (a+1, A +1+n,cmp); for(intI=1; i<=n;i++) if(1.0* (a[i].x+a[n-i+1].x)/2!=xx| |1.0* (a[i].y+a[n-i+1].Y)/2!=yy) {printf ("This is a dangerous situation!"); return 0; } printf ("V.I.P. Should stay at (%.1LF,%.1LF).", Xx,yy); return 0;}
AC Code
Rokua--p1227 [JSOI2008] Perfect symmetry