Rokua 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 sampleInput Sample # #:
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

I got one hours of the provincial selection, incredibly is sort+o (N) judgment ~ ~ ~ I, I didn't think of it.

1#include <iostream>2#include <algorithm>3#include <cstring>4#include <cstdio>5#include <cstdlib>6 using namespacestd;7 #defineMAXN 200108 structnode{Doublex, y;} NODE[MAXN];9 intN;Ten BOOLCMP (Node A,node b) { One     if(a.x!=b.x)returna.x<b.x; A     returna.y<b.y; - } - intMain () { thescanf"%d",&n); -      for(intI=1; i<=n;i++) -scanf"%LF%LF",&node[i].x,&node[i].y); -Sort (node+1, node+n+1, CMP); + //for (int i=1;i<=n;i++) - //printf ("%lf%lf\n", node[i].x,node[i].y); +     DoubleLastx= (node[1].x+node[n].x)/2.0; A     DoubleLasty= (node[1].Y+NODE[N].Y)/2.0; at      for(intI=2; i<=n/2; i++){ -         DoubleP= (node[i].x+node[n-i+1].x)/2.0; -         DoubleQ= (node[i].y+node[n-i+1].Y)/2.0; -         if(p==lastx&&q==lasty)Continue; -         Else { -printf"This is a dangerous situation!"); in             return 0; -         } to     } +printf"V.I.P. Should stay at (%.1LF,", LASTX); -printf"%.1lf).", lasty); the     return 0; *}

Rokua 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.