loj#P6803. 「ICPC World Finals 2020」胜利者,我们的向量是什么?
「ICPC World Finals 2020」胜利者,我们的向量是什么?
Description
Vector embeddings are a common tool in machine learning systems. Complex real-world concepts (for instance, words in a dictionary) are mapped onto vectors of real numbers. If embeddings are trained properly, related concepts remain close together in the vector space, so questions like "are these two words synonyms?" can be reduced to straightforward mathematical tests.
You have been hired by Ye Olde Ice Cream Shoppe to create an embedding model for flavors, so that when they are out of an ice cream flavor they can recommend related flavors to customers. After training your embedding on six cloud datacenters for four months, you finally had the perfect flavor model! You were ready to revolutionize the ice cream industry on your street and, dare we say it, your neighborhood! Well, until you accidentally dripped some free ice cream on your keyboard and deleted half the data. The Shoppe cannot afford the 30 billion rubles needed to retrain the model, so you are in trouble.
Fortunately, you still have various training results lying around. For a given deleted vector, the training data tells you how close it was to some known flavor vectors. The closeness of vectors and is just the standard Euclidean distance metric (that is, the length of the vector ). Write a tool that reconstructs embeddings which are consistent with the training results.
Input
The first line contains two integers and , where () is the number of dimensions of the vectors, and () is the number of training results for a deleted embedding vector you want to reconstruct. Each of the next lines describes a training result using numbers and . In a training result, () are the coordinates of a known vector, and () is the Euclidean distance from that vector to the deleted one.
Your submission will be tested only with the sample inputs given below and inputs generated according to the following procedure. First, and are chosen. Then, input vectors and output vector, each with dimension , are chosen at random. The coordinates are independent and uniformly distributed in the interval . Next, the Euclidean distance from each input vector to the output vector is computed. Finally, the output vector is discarded. Calculations use double-precision floating-point numbers. Numbers obtained using this procedure appear in the input with digits after the decimal point.
Output
Output values, the coordinates of any vector that has the given distance to each training vector with an absolute or relative error of at most .
2 3
0 0 2.5
3 0 2.5
1.5 0.5 2.5
1.5 -2
2 2
0 0 2
4 -4 6
1.414213562373 1.414213562373
4 3
0 1 2 3 2
1 2 -1 7 5
1 0.3 3.4 1.2 3.3
1 2 3 4