Translation Notice
This article was machine-translated using DeepSeek-R1.
- Original Version: Authored in Chinese by myself
- Accuracy Advisory: Potential discrepancies may exist between translations
- Precedence: The Chinese text shall prevail in case of ambiguity
- Feedback: Technical suggestions regarding translation quality are welcomed
The problem titles in this contest are unique, composed of symbols + (+English+)
:)
C - : (Colon)
Problem Statement
At $A$ hours and $B$ minutes, what is the distance between the tips of the hour hand of length $H$ centimeters and the minute hand of length $M$ centimeters?
$1\le A, B\le 1000$
$0\le H\le 11$
$0\le M\le 59$
(Floating-point precision errors up to $10^{-9}$ are allowed)
Input Format
$A~B~H~M$
Output Format
A single line with the distance between the two points.
Samples
Sample Input 1
|
|
Sample Output 1
|
|
Sample Input 2
|
|
Sample Output 2
|
|
Analysis
$$C^2=A^2+B^2-2AB\cos\theta$$
Note: In C/C++, the parameter of the cos
function is in radians. If θ is in degrees, use cos(theta / 180 * PI)
.
Code
Finally, the code:
|
|
D - . . (Double Dots)
Problem Statement
A cave has $N$ rooms and $M$ passages.
Rooms are numbered $1$ to $N$, passages are numbered $1$ to $M$. Each passage bidirectionally connects rooms $A_i$ and $B_i$ ($1\le i\le M$). Room $1$ is the exit.
Each room (except room $1$) must have a sign pointing to an adjacent room. Following these signs from any room must yield the shortest path to the exit.
$2\le N\le 10^5$
$1\le M\le 2 \times 10^5$
$1\le A_i, B_i\le N$ ($1\le i\le M$)
$A_i≠B_i$ ($1\le i\le M$)
Input Format
$N~M$
$A_1~B_1$
$\vdots$
$A_M~B_M$
Output Format
If no solution exists, output No
.
If a solution exists:
- First line:
Yes
- Line $i$: The room number pointed by the sign in room $i$ ($2\le i\le N$).
Analysis
Clearly a BFS problem. Note: If the cave is disconnected, there is no solution.
Code
|
|