当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6912:Let’s Get Married

题目描述
“Don’t wanna walk alone. So, let’s get married.”

Little Y lives in a strange town, which can be represented by a finite 2D plane. Each grid point on the 2D plane has a unique number. The unique number is generated by breadth first search. The origin point (0,0) is numbered as 0. We search for the points which is not accessed yet (in the order of top, right, bottom, left) and number them with the smallest available positive number.

$$
\begin{matrix}
& & 5 & & \\
& 7 & 1 & 6 & \\
\cdots & 4 & 0 & 2 & 8 \\
& \cdots & 3 & 9 & \\
& & \cdots & &
\end{matrix}
$$

For example, the point (1,-1) is for 9 and the point 6 is at (1,1).

One day, Little Y met Little K and quickly fell in love.

Little Y wants to follow Little K’s steps. Surprisingly, Little K will publish his location.

Once noticing the location, Little Y will go to that point. However, Little Y is not clever and need your help.
输入解释
The first line contains T (1 ≤ T ≤ $10^4$), denoting the number of Little K’s position.

The next T lines contains the messages in the following two ways.

$\quad \cdot$ 1 id for the unique number

$\quad \cdot$ 2 x y for the position

It is guaranteed that all points satisfy |x|+|y| ≤ $10^8$
输出解释
Initially, ($x_{current}, y_{current}$) is set to (0,0).

For each message, you should help Little Y in the following instructions.

For 1 id, you should output the position difference (x-$x_{current}$, y-$y_{current}$) of point id at (x,y).

For 2 x y, you should output the unique number of the point at this position.

After processing the current message, ($x_{current}, y_{current}$) will be set to (x,y).
输入样例
6
1 8
2 3 3
1 14
2 5 1
1 2
1 0
输出样例
2 0
66
-2 -1
70
-4 -1
-1 0
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6912

最后修改于 2021-06-22T18:18:51+00:00 由爬虫自动更新

共提交 4

通过率 0.0%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)