#P4546. [THUWC 2017] 在美妙的数学王国中畅游
[THUWC 2017] 在美妙的数学王国中畅游
Description
The underachiever Xiao R (pinyin) was tortured by university mathematics courses to the point of being unable to take care of himself. His calculus score was once the lowest among all the courses he took in the classroom. However, one of his roommates surnamed Chen could easily get full marks in math exams. To improve his math grades, one night (in his sleep), he arrived at the Kingdom of Mathematics.
In the Kingdom of Mathematics, everyone’s IQ is represented by a real number in . There are cities numbered from , connected by several magic bridges. At the center of each city there is a magic orb, and inside each magic orb lies a math problem.
After solving this problem, everyone will receive a score in . A problem can be represented by a function . If a person’s IQ is , then after solving this problem he will receive points. There are three forms:
- Sine function $f(x)=\sin(a x + b)\ (a \in [0,1], b \in [0,\pi],a+b\in[0,\pi])$.
- Exponential function $f(x)=\text e^{ax+b}\ (a\in [-1,1], b\in [-2,0], a+b\in [-2,0])$.
- Linear function $f(x) = ax + b\ (a\in [-1,1],b\in[0,1],a+b\in [0,1])$.
The magic bridges in the Kingdom of Mathematics change over time. Sometimes a magic bridge disappears, and sometimes a magic bridge appears. However, at any moment, there exists at most one simple path connecting any two cities (i.e., all cities form a forest). Initially, there are no magic bridges in the Kingdom of Mathematics.
King Lagrange of the Kingdom of Mathematics is happy to teach Xiao R (pinyin) math, but only if Xiao R first answers the king’s questions. These questions have the same form: for a person with IQ traveling from city to city (i.e., passing through all cities on the path , including and ) and solving all the problems in those cities, what is the sum of all his scores.
Input Format
The first line contains two positive integers and a string . They indicate that there are cities in the Kingdom of Mathematics, events occur, and the type of this testdata is .
The string is provided to help you obtain partial scores more easily; you may not need to use it. Its meaning is explained in Constraints and Assumptions.
The next lines describe, for each city , the function inside its magic orb in the initial state. One integer denotes the type of function, and two real numbers denote the parameters. If
- , then the function is .
- , then the function is .
- , then the function is .
The next lines each describe an event, of one of four types.
appear u vmeans a magic bridge appears between cities and . It is guaranteed that before adding the bridge, and are not reachable from each other.disappear u vmeans the magic bridge between and disappears. It is guaranteed that this magic bridge exists.magic c f a bmeans the magic orb in city changes to a function of type with parameters .travel u v xasks: for a person with IQ traveling from city to city , what is the sum of his scores. If cannot reach , output a single line containing the stringunreachable.
Output Format
For each query, output one line with a real number representing the total score.
3 7 C1
1 1 0
3 0.5 0.5
3 -0.5 0.7
appear 0 1
travel 0 1 0.3
appear 0 2
travel 1 2 0.5
disappear 0 1
appear 1 2
travel 1 2 0.5
9.45520207e-001
1.67942554e+000
1.20000000e+000
Hint
Constraints and Assumptions.
For of the data, .
There are 20 testdata points, each worth 5 points.
| 测试点 | 数据类型 | ||
|---|---|---|---|
| C1 | |||
| A0 | |||
| B0 | |||
| D0 | |||
| A1 | |||
| C1 | |||
| D1 |
Meaning of data types:
-
A: There is no
disappearevent, and in allappearevents, . -
B: There is no
disappearevent. -
C: The total number of cities traversed over all
travelevents is (pairs that are unreachable are not counted). -
D: No further restrictions.
-
0: In all
travelevents, (i.e., everyone’s IQ is ). -
1: No restriction.
Scoring criteria.
If your answer differs from the standard answer by a relative error within or an absolute error within , it is considered correct.
You will receive full score only if all your answers are correct; otherwise, you receive 0 points.
Please pay attention to the output format: print one answer per line, and each line must be either unreachable or a real number (scientific notation is recommended). Each line must not exceed 50 characters. Incorrect output format will result in 0 points.
Xiao R Teaches You Math.
If the -th derivative of a function is continuous on the interval , then by applying the Lagrange mean value theorem times to at , we obtain the Taylor expansion with Lagrange remainder
$$f(x)=\sum_{k=0}^{n-1}\frac{f^{(k)}(x_0)(x-x_0)^k}{k!}+\frac{f^{(n)}(\xi)(x-x_0)^n}{n!},x\in[a,b]$$where, when , . When , .
denotes the -th derivative of the function .
Translated by ChatGPT 5
京公网安备 11011102002149号