Horse Drinks Water官方中文
题目描述
官方中文This problem is a variant of the General’s Horse Drinking Water problem. Given that the general’s horse is at point $(x_G, y_G)$, the tent is at point $(x_T, y_T)$, and the river is located along the positive half of the x-axis and the positive half of the y-axis, find the shortest distance the horse needs to travel to drink water from the river and return to the tent.官方中文
输入格式
官方中文Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \leq t \leq 10^5$). The description of the test cases follows.
Each test case consists of a single line containing four integers $x_G, y_G, x_T, y_T$ ($0 \leq x_G, y_G, x_T, y_T \leq 10^9$), describing the positions of the general’s horse and the tent.官方中文
输出格式
官方中文For each test case, output a decimal number representing the shortest distance the horse needs to travel to drink water from the river and return to the tent.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-9}$.
Formally, let your answer be $a$, and the jury’s answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max(1, |b|)} \leq 10^{-9}$.官方中文
说明
官方中文In test case 3, the optimal path is:官方中文
样例
5
1 3 3 3
1 1 1 1
1 5 4 2
11 4 5 14
19 1 9 8104
2
5.8309518948
18.8679622641
809.4844038028题面与样例版权归 牛客竞赛 及出题人所有;中文翻译由 AI 生成(官方原文),如有出入请以原文为准。