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

建议使用的浏览器:

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

7051:Smzzl with Greedy Snake

题目描述
Smzzl is going to make an AI for Greedy Snake. The game goes on xOy plane and there is no obstacles in the plane.

In this game, the snake takes $1$ unit of time to move forward for one unit of length. It also takes $1$ unit of time for the snake to rotate for 90 degrees. (The snake must rotate for the whole unit of time.) There is a food in the map initially. After the snake eat each food, the next food appears.

Smzzl certainly want the snake to eat the food as fast as possible, so he need to minimize the time when the snake eat each food. Please output a valid operate sequence.
输入解释
The input consists of multiple test cases.

The first line contains an integer $T$ ($1 \leq T \leq 200$) -- the number of test cases.

For each test case:

In the first line, there are three integers $x,y,d$ ($|x|,|y| \leq 10^4$, $0 \leq d \leq 3$). The snake starts on $(x,y)$. $d$ shows the direction of the head of the snake. (0 for y+, 1 for x+, 2 for y-, 3 for x-)

In the second line, there is an integer $n$ ($1 \leq n \leq 10^5$), which is the number of foods.

In the next $n$ lines, each contains two integers $x,y$ ($|x|,|y| \leq 10^4$), which means the next food appears at $(x,y)$.

It is guaranteed that any line that connects two foods that appear adjacently does not parallel to the x-axis or the y-axis.

输出解释
For each test case, output the shortest operation sequence. Output 'f' for going forward, 'c' for rotating clockwise, 'u' for rotating counterclockwise. Each operation lasts for one unit of time.

It can be proved that there is only one operation sequence which meets the requirements.

It is guranteed that the total length of output does not exceed $2 \times 10^6$.
输入样例
2
0 0 0
2
-1 -1
1 1
0 0 2
5
-1 2
2 4
3 -5
4 -2
5 0
输出样例
ufufuffuff
cfcffffcffffcfffffffffufufffffcf

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

源链接: HDU-7051

最后修改于 2021-10-23T19:11:13+00:00 由爬虫自动更新

共提交 0

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