eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Directional Resemblance

Directional Resemblance

Vectors have their directions and two vectors make an angle between them. Given a set of three-dimensional vectors, your task is to find the pair among them that makes the smallest angle. \InputFile The input is a sequence of datasets. A dataset specifies a set of three-dimensional vectors, some of which are directly given in the dataset and the others are generated by the procedure described below. Each dataset is formatted as follows. \textbf{m n S W} \textbf{x_1 y_1 z_1} \textbf{x_2 y_2 z_2} \textbf{...} \textbf{x_m y_m z_m} The first line contains four integers \textbf{m}, \textbf{n}, \textbf{S}, and \textbf{W}. The integer \textbf{m} is the number of vectors whose three components are directly specified in the dataset. Starting from the second line, \textbf{m} lines have the three components of \textbf{m} vectors. The \textbf{i}-th line of which indicates the vector \textbf{v_\{i \}= (x_i, y_i, z_i)}. All the vector components are positive integers less than or equal to \textbf{100}. The integer \textbf{n} is the number of vectors generated by the following procedure. \textbf{int g = S;} \textbf{for (int i=m+1; i<=m+n; i++) \{} \textbf{x\[i\] = (g/7) \%100 + 1;} \textbf{y\[i\] = (g/700) \%100 + 1;} \textbf{z\[i\] = (g/70000)\%100 + 1;} \textbf{if( g\%2 == 0 ) \{ g = (g/2); \}} \textbf{else \{ g = (g/2) ^ W; \}} \textbf{\}} For \textbf{i = m+1}, ..., \textbf{m+n}, the \textbf{i}-th vector \textbf{v_i} of the set has three components \textbf{x\[i\]}, \textbf{y\[i\]}, and \textbf{z\[i\]} generated by this procedure. Here, values of \textbf{S} and \textbf{W} are the parameters \textbf{S} and \textbf{W} given in the first line of the dataset. You may assume \textbf{1} ≤ \textbf{S }≤ \textbf{10^9} and \textbf{1} ≤ \textbf{W} ≤ \textbf{10^9}. The total number of vectors satisfies \textbf{2} ≤ \textbf{m+n} ≤ \textbf{12}×\textbf{10^4}. Note that exactly the same vector may be specified twice or more in a single dataset. A line containing four zeros indicates the end of the input. The total of \textbf{m+n} for all the datasets in the input never exceeds \textbf{16}×\textbf{10^5}. \OutputFile For each dataset, output the pair of vectors among the specified set with the smallest non-zero angle in between. It is assured that there are at least two vectors having different directions. Vectors should be indicated by their three components. The output for a pair of vectors \textbf{v_a} and \textbf{v_b} should be formatted in a line as follows. \textbf{x_a y_a z_a x_b y_b z_b} Two vectors \textbf{(x_a, y_a, z_a)} and \textbf{(x_b, y_b, z_b)} are ordered in the dictionary order, that is, \textbf{v_a} < \textbf{v_b} if \textbf{x_a} < \textbf{x_b}, or if \textbf{x_\{a \}= x_\{b \}}and \textbf{y_a} < \textbf{y_b}, or if \textbf{x_a = x_b}, \textbf{y_a = y_b} and \textbf{z_a} < \textbf{z_b}. When a vector pair is output, the smaller vector in this order should be output first. If more than one pair makes the equal smallest angle, the pair that is the smallest among them in the dictionary order between vector pairs should be output. The pair \textbf{(v_i, v_j)} is smaller than the pair \textbf{(v_k, v_l)} if \textbf{v_i} < \textbf{v_k}, or if \textbf{v_\{i \}= v_\{k \}}and \textbf{v_j} < \textbf{v_l}.
Ліміт часу 60 секунд
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
4 0 2013 1124
1 1 1
2 2 2
2 1 1
1 2 1
2 100 131832453 129800231
42 40 46
42 40 46
0 100000 7004674 484521438
0 0 0 0
Вихідні дані #1
1 1 1 1 2 1
42 40 46 83 79 91
92 92 79 99 99 85
Джерело ACM International Collegiate Programming Contest, Asia Regional Contest, Aizu, 2013–11–24