#P3843. [TJOI2007] 迷路
[TJOI2007] 迷路
Description
Both people walk at a speed of 1 unit per second, and all their route segments are parallel to the coordinate axes. Based on this, if the two keep walking indefinitely, we want to know the smallest distance between them measured at the end of each second. We only consider the distance after each whole second of walking, not the distance at any moment within a second.
Input Format
The input consists of two similar parts, describing the orbits of Xiao A and Xiao B respectively.
For each part:
- The first line contains three integers: sx, sy, and m. The first two integers are the initial position, and the third is the number of polyline segments in the orbit.
- The next m lines each contain an integer d and a non-space character c, separated by one space. Here d is the distance walked in the positive direction of the specified coordinate axis, and c is 'X' or 'Y', indicating whether the movement is parallel to the X-axis or the Y-axis.
It is guaranteed that, for each part, starting from (sx, sy) and performing these m walking steps, you will return to the starting point; that is, the orbit is closed.
Output Format
Output a single real number with exactly two digits after the decimal point, representing the smallest observable distance between the two people. If it is possible for them to arrive at the same point at some integer time, output 0.00.
0 0 4
-1 Y
-1 X
1 Y
1 X
1 0 4
-1 X
1 Y
1 X
-1 Y
1.00
Hint
For 100% of the testdata, , and the absolute value of the initial coordinates does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号