#P6214. 「SWTR-4」Taking a Walk
「SWTR-4」Taking a Walk
Background
Little A likes taking a walk in the square.
Once, while Little A was walking, he was thinking too deeply and accidentally ran into a utility pole.
So this problem came out (of course, it is fake).
Problem Description
Little A and his friend Little Y are standing on a plane. Their initial coordinates are and , respectively.
Of course, standing still is too boring, so they will keep moving.
More precisely, Little A makes a total of moves, and Little Y makes a total of moves.
From time to time , Little A moves from to with uniform linear motion.
From time to time , Little Y moves from to with uniform linear motion.
- .
Little A also has queries. Each query gives a floating-point number and an integer , asking you to find the time when their distance is for the -th time.
-
Special case: if there are infinitely many times when their distance is , output
-2.33. -
Special case: if is greater than the number of times their distance is , output
-4.66. -
Otherwise, output the time when their distance is for the -th time.
Input Format
The first line contains three integers , where is the number of moves of Little A, is the number of moves of Little Y, and is the number of queries.
The second line contains four floating-point numbers with two decimal places , representing the initial coordinates of Little A and Little Y.
The next lines: the -th line contains three floating-point numbers with two decimal places , as described above.
The next lines: the -th line contains three floating-point numbers with two decimal places , same as above.
The next lines: each line contains a floating-point number with two decimal places and an integer , describing a query.
Output Format
Output floating-point numbers in total, representing the answer to each query.
3 3 10
0.00 0.00 0.00 1.00
-1.00 -1.00 0.20
10.00 10.00 0.41
-4.56 -1.23 1.00
-2.00 -1.00 0.40
-10.00 -10.00 0.41
9.87 6.54 1.00
0.00 1
1.00 1
5.00 1
5.00 3
5.00 4
10.00 2
10.00 6
28.28 1
28.28 2
28.29 1
-4.66
-2.33
0.26970954
0.83836048
-4.66
0.65792852
-4.66
0.40999665
0.41005730
-4.66
Hint
Special Judge
This problem uses Special Judge.
If the relative error or absolute error between your output and the correct answer is at most , you will get full score for that test point. Otherwise, you will get no score. It is recommended to output at least digits after the decimal point.
Please do not output any numbers other than what the problem asks for, otherwise you may get UKE.
It is guaranteed that there is no case where the answer is .
The SPJ is as follows:
#include "testlib.h"
#define double long double
const double eps=1e-7;
bool Equal(double x,double y){
return abs(x-y)<=eps||abs((x-y)/y)<=eps;
}
int main(int argc, char* argv[]){
registerTestlibCmd(argc, argv);
int n=inf.readInt(),m=inf.readInt(),q=inf.readInt();
for(int i=1;i<=q;i++){
double x=ouf.readDouble(),y=ans.readDouble();
if(!Equal(x,y))quitf(_wa,"On line %d the answer is wrong: expected = %.8LF, found = %.8LF",i,y,x);
}
quitf(_ok, "The answer is correct.");
return 0;
}
Constraints and Notes
This problem uses bundled testdata.
| Subtask ID | Score | ||
|---|---|---|---|
For of the data, , , , , .
To ensure accuracy on extreme testdata, the absolute value of all coordinates is at most .
It is guaranteed that and . The duration of a single move is at most . It is not guaranteed that a move actually changes the position.
Please pay attention to precision errors.
Time & Memory Limits
For Subtask , the time limit is , and for the other subtasks the time limit is .
For Subtask , the memory limit is , and for the other subtasks the memory limit is .
To eliminate incorrect solutions, the setter shortened the time limit, but it is still more than times that of the std.
The std is slightly tight on constants. Please pay attention to I/O and constant-factor optimizations.
This problem enables automatic O2 optimization.
Source
Sweet Round 04 F.
Idea & std: Alex_Wei。
Translated by ChatGPT 5