#P3707. High-Dimensional Vector Correspondence

    ID: 2716 远端评测题 10000ms 64MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>POJ Founder Monthly Contest – 2008.12.28, frkstyc

High-Dimensional Vector Correspondence

Description

Let < p1, p2,..., pn > and < q1, q2,..., qn > be two sequences of vectors in the m-dimensional Euclidean space. Is that possible to transform the former using a series of reflections and/or rotations so that it becomes the latter?

Input

The input consists of a single data set given in the format (n, m ≤ 512)


\begin{tabular}{cccc} \textit{m} & \textit{n} & & \\ \textit{p}<span>$</span>_{11}<span>$</span> & \textit{p}<span>$</span>_{12}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{p}<span>$</span>_{1m}<span>$</span> \\ \textit{p}<span>$</span>_{21}<span>$</span> & \textit{p}<span>$</span>_{22}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{p}<span>$</span>_{2m}<span>$</span> \\ <span>$</span>\vdots<span>$</span> & <span>$</span>\vdots<span>$</span> & <span>$</span>\ddots<span>$</span> & <span>$</span>\vdots<span>$</span> \\ \textit{p}<span>$</span>_{n1}<span>$</span> & \textit{p}<span>$</span>_{n2}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{p}<span>$</span>_{nm}<span>$</span> \\ \textit{q}<span>$</span>_{11}<span>$</span> & \textit{q}<span>$</span>_{12}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{q}<span>$</span>_{1m}<span>$</span> \\ \textit{q}<span>$</span>_{21}<span>$</span> & \textit{q}<span>$</span>_{22}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{q}<span>$</span>_{2m}<span>$</span> \\ <span>$</span>\vdots<span>$</span> & <span>$</span>\vdots<span>$</span> & <span>$</span>\ddots<span>$</span> & <span>$</span>\vdots<span>$</span> \\ \textit{q}<span>$</span>_{n1}<span>$</span> & \textit{q}<span>$</span>_{n2}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{q}<span>$</span>_{nm}<span>$</span>\\ \end{tabular}

where


\begin{tabular}{c} \textit{\textbf{p}}<span>$</span>_i<span>$</span>=[\textit{p}<span>$</span>_{11}<span>$</span>\quad\textit{p}<span>$</span>_{12}<span>$</span>\quad <span>$</span>\cdots<span>$</span>\quad\textit{p}<span>$</span>_{1m}<span>$</span>]\textsuperscript{T} \\ \textit{\textbf{q}}<span>$</span>_i<span>$</span>=[\textit{q}<span>$</span>_{11}<span>$</span>\quad\textit{q}<span>$</span>_{12}<span>$</span>\quad <span>$</span>\cdots<span>$</span>\quad\textit{q}<span>$</span>_{1m}<span>$</span>]\textsuperscript{T} \\ \end{tabular}

for all 1≤i≤n. All numbers except m and n are floating-point. Blank characters are irrevelant.

Output

It is known that both reflections and rotations are linear transformations, which are represented by squarematrices. In particular, in the m-dimensional Euclidean space, they are represented by m × m matrices. Furthermore, composition of linear transformations is represented by the product of the corresponding matrices. Therefore, if the desire sequence of reflections and rotations exists, you are to output a matrix H in the format


\begin{tabular}{cccc} \textit{m} & & & \\ \textit{h}<span>$</span>_{11}<span>$</span> & \textit{h}<span>$</span>_{12}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{h}<span>$</span>_{1m}<span>$</span> \\ \textit{h}<span>$</span>_{21}<span>$</span> & \textit{h}<span>$</span>_{22}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{h}<span>$</span>_{2m}<span>$</span> \\ <span>$</span>\vdots<span>$</span> & <span>$</span>\vdots<span>$</span> & <span>$</span>\ddots<span>$</span> & <span>$</span>\vdots<span>$</span> \\ \textit{h}<span>$</span>_{m1}<span>$</span> & \textit{h}<span>$</span>_{m2}<span>$</span> & <span>$</span>\cdots<span>$</span> & \textit{h}<span>$</span>_{mm}<span>$</span> \\ \end{tabular}

such that Hpi = qi for all 1≤i≤n; otherwise, you only have to output an asterisk ("*"). Blank characters are irrevelant.

2 2
-0.923896909208131 -0.150594719880319
-3.269301773087776E-002 0.871630392603206
0.402113583440769 -0.845321793468377
0.735234663492202 0.469295604408862
2
-0.569248928113214700 0.822165225390831260 
0.822165225390831590 0.569248928113214810 

Source

POJ Founder Monthly Contest – 2008.12.28, frkstyc