Decadent one afternoon, has been in the water shearing problem, (ˉ▽ ̄~)
First, if these points are symmetrical, then their symmetric axes are x = M,m is the average of the horizontal axis.
Place these points in a set and then scan each point to calculate its symmetry point for x = m to see if the point is in the set.
If one is not present, the description cannot form a symmetric graphic.
1#include <cstdio>2#include <algorithm>3#include <Set>4 using namespacestd;5 6 struct Point7 {8 intx, y;9Point (intx =0,inty =0): X (x), Y (y) {}Ten BOOL operator< (Constpoint& RHS)Const One{returnX < Rhs.x | | (x = = Rhs.x && y <rhs.y); } A }; - - Const intMAXN = ++Ten; the Point P[MAXN]; - - intMain () - { + //freopen ("In.txt", "R", stdin); - + intT, N; Ascanf"%d", &T); at while(t--) - { -scanf"%d", &n); - Set<Point>hehe; - Doubles =0, M; - for(inti =0; I < n; i++) in { -scanf"%d%d", &p[i].x, &p[i].y); to Hehe.insert (P[i]); +s + =p[i].x; - } them = S/N; * BOOLOK =true; $ for(inti =0; I < n; i++)Panax Notoginseng { -Point T ((int) (m*2)-p[i].x, p[i].y); the if(!hehe.count (t)) {OK =false; Break; } + } Aprintf"%s\n"Ok?"YES":"NO"); the } + - return 0; $}code June
UVa 1595 (water problem) symmetry