#C9117. Drone Delivery: Minimum Moves
Drone Delivery: Minimum Moves
Drone Delivery: Minimum Moves
A drone starts at the warehouse located at ( (0, 0) ). It needs to deliver packages to several destinations. For each destination with coordinates ( (x, y) ), the drone must take the minimum number of moves to reach the destination. A move is defined as moving one unit horizontally or vertically. Hence, the minimum number of moves required for a destination is given by the Manhattan distance ( |x| + |y| ).
You are given multiple test cases. In each test case, the first number is ( N ), which denotes the number of destinations, followed by ( N ) pairs of integers representing the coordinates of each destination. Your task is to compute and output the Manhattan distance (the minimum moves) from the warehouse to each destination in the same order as given.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer ( T ), denoting the number of test cases.
- For each test case:
- The first line contains an integer ( N ), the number of destinations.
- The next ( N ) lines each contain two space-separated integers ( x ) and ( y ), representing the coordinates of a destination.
For example:
2 3 1 2 3 4 -1 -1 2 0 0 1 1
outputFormat
For each test case, output a single line on standard output (stdout) containing ( N ) space-separated integers. Each integer is the minimum number of moves (i.e. the Manhattan distance, ( |x| + |y| )) from the warehouse ( (0, 0) ) to the corresponding destination.
For the sample input above, the output should be:
3 7 2 0 2## sample
2
3
1 2
3 4
-1 -1
2
0 0
1 1
3 7 2
0 2
</p>