#P2603. [ZJOI2008] 无序运动
[ZJOI2008] 无序运动
Description
Dr. D has conducted in-depth research in physics, with theorems in classical physics, astrophysics, and quantum physics named after him. Recently, he has been fascinated by the irregularity of particle motion. Firmly believing in the Bible, he is convinced that anything created by God must be orderly and rational, rather than random and chaotic.
After long study, Dr. D found many trajectory fragments that appear quite frequently and stored them in a large database. He needs you to write a program that, for a given particle trajectory, counts the number of occurrences of each trajectory fragment from the database.
For clarity, we define a particle’s trajectory as a sequence of points on a 2D plane, . A subarray of the point sequence is defined as a contiguous subsequence in , . A subarray of the point sequence is called an occurrence of the point sequence in if and only if, after a finite number of translations, rotations, reflections, and scalings, we obtain such that , .
Explanations for the four operations on point sequences: |Operation|Explanation| |:-:|:-:| |Translation|Let the translation vector be . Then any point is mapped to .| |Rotation|Let the rotation angle be . Then any point is mapped to .| |Reflection|Any point is mapped to .| |Scaling|Let the scaling factor be . Then any point is mapped to .|
Input Format
The first line contains two integers , representing the size of the point sequence of the trajectory to be processed and the number of trajectory fragments in the database, respectively.
The next lines describe each trajectory fragment in order. Each line starts with a positive integer , the length of the point sequence of that fragment. Then integers follow, describing the points’ - and -coordinates in order.
The next line contains integers, describing the - and -coordinates of the points in the point sequence of the trajectory to be processed, in order.
Note: In every trajectory in the input, any two adjacent points are different.
Output Format
Output lines. For each fragment, output the number of its occurrences in the trajectory to be processed, in order.
3 2
2 17 0 10 1
3 0 0 1 0 1 -1
0 0 1 0 1 1
2
1
Hint
Let the total length of all fragments be .
Constraints:
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , , and it is guaranteed that the absolute value of every given point coordinate in the input does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号