Food Delivery
InterviewTime limit8sMemory limit1024 MB
Find the weighted balance point row and column from a grid of food weights.
- Level
Easy2 of 10
- Topics
- Implementation, Matrix, Math
- Solved
- No attempts yet
Problem
The food delivery service UnterEats delivers food in custom containers designed by the world-famous designer X to raise both the company's brand value and its transport efficiency at the same time.
The container was excellent, but the couriers who actually used it rated it very poorly. It had no handles. Couriers had to support the container from below at just the right balance point, and accidents in which they lost their balance and ruined the food happened often.
UnterEats tried to add handles. When the company consulted X, X became furious and insisted that there could not be anything wrong with the design. X then threatened a lawsuit if the company tried to add handles anyway. Left with no choice, you, a software engineer at UnterEats, are to develop software that computes where to hold the container from the arrangement of the food.
The container has square cells packed in rows and columns. When the cell in the -th row from the top and the -th column from the left contains food of weight , find a pair of real numbers that satisfies the following two equations.
Input
Input consists of at most 50 datasets. Each dataset is given in the following format.
H W
v1,1v1,2...v1,W
v2,1v2,2...v2,W
…
vH,1vH,2...vH,W
The first line contains two integers and () representing the size of the container. From the second line to the -th line, each line contains a string of digits. The number represented by the digit in row , column is (). For each dataset, the sum of is positive. The end of the input is a line containing two zeros separated by a space.
Output
For each dataset, print and in that order, separated by a space, on one line. An output is accepted if the absolute error of both and from the true solution is at most .