"Luo gu" P1227 [JSOI2008] Perfect symmetry

Source: Internet
Author: User

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/Output sample

Input Sample # #:

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

Sample # # of output:

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

Description

[JSOI2008] Second round

Exercises

This question is probably over the years Jsoi province selected the most simple problem, the difficulty should only Noip universal group T2~T3 (should not be T3 difficulty).

We find that the hypothesis (a, a, a, b) is the symmetry center of the graph, then (x1,y1), (X2,y2) is centered on this symmetry (provided that there are these two points), obviously: a = (x1+x2)/2; b = (y1+y2)/2;

And then all 2 of these pairs of points satisfy this equation, we might as well reverse This process, that is, the average of the horizontal axis of all points is the horizontal axis of the symmetry center, the ordinate of all points is the ordinate of the symmetry center. This will find the symmetry center.

Then all points are x as the first keyword, and y for the second keyword from small to large sort. Then test whether the first and second points (n-i+1) meet the above equation to determine whether the data is legitimate.

Code:

#include <bits/stdc++.h>using namespace Std;inline int read () {int f=1,x=0; char S=getchar (); while (s< ' 0 ' | | s > ' 9 ') {if (s== '-') F=-1;s=getchar ();} while (s>= ' 0 ' && s<= ' 9 ') {x = x*10+s-' 0 '; S=getchar ();} return x*f;} struct Node{int x,y;void Read () {x = read (); y = read ();}} A[20010];int N; BOOL CMP (node A,node b) {if (a.x = = b.x) return a.y<b.y; else return a.x<b.x;} int main () {scanf ("%d", &n), long long sumx = 0, Sumy = 0;for (int i = 1; I <= n; i++) {a[i]. Read (); sumx + = a[i].x; Sumy + = A[i].y;}  Double xx = sumx*1.0/n, yy = sumy*1.0/n;int tx = Floor (xx*2), Ty = Floor (yy*2), bool F = 1;sort (a+1,a+1+n,cmp); for (int i = 1; I <= N/2; i + +) if (a[i].x+a[n-i+1].x! = TX | | a[i].y+a[n-i+1].y! = ty) {f = 0;break;} if (f = = 1) printf ("V.I.P. should stay at (%.1f,%.1f). \ n", xx,yy); else printf ("This is a dangerous situation!"); return 0;}

  

Valley P1227 [JSOI2008] 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.