luogu#P5139. z小f的函数

z小f的函数

Background

z Xiao f loves mathematics.

Because z Xiao f needs to review for NOIp, and he thinks the math homework is too easy, he handed the math homework to you.

Problem Description

Given a quadratic function y=ax2+bx+c(a0)y=ax^{2}+bx+c(a\ne0), perform the following operations on the function:

  • Operation 1: Given a coefficient kk, shift the function upward by kk units (if k<0k<0, shift downward by k-k units).
  • Operation 2: Given a coefficient kk, shift the function rightward by kk units (if k<0k<0, shift leftward by k-k units).
  • Operation 3: Given coefficients k1,k2k_1,k_2, perform a symmetry transformation of the function with respect to the point (k1,k2)(k_1,k_2).
  • Operation 4: Given coefficients k1,k2k_1,k_2, find the minimum and maximum values of the function on the closed interval [k1,k2][k_1,k_2].
  • Operation 5: Given coefficients u,v,wu,v,w, determine whether the quadratic function yy intersects with the quadratic function y2=ux2+vx+wy_2=ux^{2}+vx+w.

In addition, you must output the maximum (or minimum) value of the final quadratic function yy at that time.

Input Format

The first line contains a positive integer TT, indicating the number of math homework problems (i.e., the number of test cases).

Then follow TT test cases. For each test case:

The first line contains three numbers a,b,ca,b,c, representing the coefficients a,b,ca,b,c of the quadratic function.

The second line contains a positive integer nn, representing the number of operations.

The next nn lines: each line starts with an integer pp, indicating the operation number, and the following numbers are the parameters of the operation (see the Description).

The testdata is guaranteed to be valid.

Output Format

For each Operation 4, output two decimal numbers, representing the minimum and maximum values on the interval (keep two decimal places).

For each Operation 5, output one integer, where 00 means there is no intersection point, and 22 means there is an intersection point.

After completing all operations of each test case, output the maximum (or minimum) value of the final quadratic function yy at that time (keep two decimal places).

1
1 0 0
4
1 3
1 -4
4 1 2
5 -1 0 -3

0.00 3.00
0
-1.00

1
-4 10 100
15
4 0 78
5 -4 -95 -97
1 -79
4 12 54
4 -60 11
1 83
4 68 80
2 -63
1 71
1 80
3 12 67
1 60
1 41
3 35 -13
4 6 26

-23456.00 106.25
2
-11103.00 -435.00
-14979.00 27.25
-24696.00 -17712.00
-6972.00 -1892.00
0.25

Hint

For 30%30\% of the testdata, n100n\le100, and there is no Operation 3.

For 60%60\% of the testdata, n1000n\le1000.

For 100%100\% of the testdata, T10T\le10, n10000n\le10000.

The testdata guarantees $a\ne0,u\ne0,a\ne u,1\le p\le5,-100\le a,b,c,k1,k2,k,u,v,w\le100$.

Translated by ChatGPT 5