#P3454. [POI 2007] OSI-Axes of Symmetry

    ID: 4296 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>字符串计算几何2007POI(波兰)KMP 算法

[POI 2007] OSI-Axes of Symmetry

题目描述

Little Johnny - a well-respected young mathematician - has a younger sister, Justina. Johnny likes hissister very much and he gladly helps her with her homework, but, like most scientific minds, he does mindsolving the same problems again. Unfortunately, Justina is a very diligent pupil, and so she asks Johnny toreview her assignments many times, for sake of certainty. One sunny Friday, just before the famous LongMay Weekend1 the math teacher gave many exercises consisting in finding the axes of symmetry of variousgeometric figures. Justina is most likely to spend considerable amount of time solving these tasks. LittleJohnny had arranged himself a trip to the seaside long time before, nevertheless he feels obliged to help hislittle sister. Soon, he has found a solution - it would be best to write a programme that wouldease checking Justina's solutions. Since Johnny is a mathematician, not a computer scientist, and you are hisbest friend, it falls to you to write it.

Task

Write a programme that:

  • reads the descriptions of the polygons from the standard input,

  • determines the number of axes of symmetry for each one of them,

  • writes the result to the standard output.

给定一个多边形,求对称轴数量。

输入格式

In the first line of the input there is one integer tt (1t101 \le t \le 10) - it is the number of polygons, for which the number of axes of symmetry is to be determined. Next, tt descriptions of the polygons follow. The first line of each description contains one integer nn (3n100 0003 \le n \le 100\ 000) denoting the number of vertices of the polygon. In each of the following nn lines there are two integers xx and yy (100 000 000x,y100 000 000-100\ 000\ 000 \le x, y \le 100\ 000\ 000) representing the coordinates of subsequent vertices of the polygon. The polygons need not be convex, but they have no self-intersections - any two sides have at most one common point - their common endpoint, if they actually share it. Furthermore, no pair of consecutive sides is parallel.

输出格式

Your programme should output exactly tt lines, with the kk'th line containing a sole integer nkn_k - the number of axes of symmetry of the kk'th polygon.

2
12
1 -1
2 -1
2 1
1 1
1 2
-1 2
-1 1
-2 1
-2 -1
-1 -1
-1 -2
1 -2
6
-1 1
-2 0
-1 -1
1 -1
2 0
1 1
4
2