A1119 | [COCI-2007_2008-contest4]#1 KOCKE
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
A robot and five cubes are placed on an infinite board composed of unit squares. The robot and the cubes occupy one square each.
The robot can be moved in each of four directions: up, down, left and right. If the square the robot would enter contains a cube, then the robot pushes it in the direction of movement.
The cubes possess curious magnetic properties. When two cubes are in neighbouring squares (squares that share a side), they join and become one object. If the robot pushes a cube that is joined with one or more other cubes, all cubes in the group move together.
Write a program that controls the robot so that it joins all cubes into a single group which (when viewed from above) forms the letter T in the upright position (it may not be rotated).
The robot can be moved in each of four directions: up, down, left and right. If the square the robot would enter contains a cube, then the robot pushes it in the direction of movement.
The cubes possess curious magnetic properties. When two cubes are in neighbouring squares (squares that share a side), they join and become one object. If the robot pushes a cube that is joined with one or more other cubes, all cubes in the group move together.
Write a program that controls the robot so that it joins all cubes into a single group which (when viewed from above) forms the letter T in the upright position (it may not be rotated).
输入格式
The input consists of five lines. Each line contains two integers X and Y (-5 ≤ X, Y ≤ 5), the starting coordinates of one cube.
The robot is initially in square (0, 0). No cubes will be located at those coordinates.
No pair of cubes will initially be at the same or neighbouring coordinates. More precisely, no cubes will initially share a side (they may share corners).
The robot is initially in square (0, 0). No cubes will be located at those coordinates.
No pair of cubes will initially be at the same or neighbouring coordinates. More precisely, no cubes will initially share a side (they may share corners).
输出格式
Output a string of characters representing the robot's moves on a single line. Each character must be one of 'U' (up), 'D' (down), 'L' (left), 'R' (right).
The sequence must be at most 9999 characters long.
The sequence must be at most 9999 characters long.
输入输出样例
输入 #1
0 1 -1 0 1 0 0 -1 0 -3
输出 #1
DRRUUULLDD
输入 #2
-2 0 -1 -1 0 -2 1 0 0 1
输出 #2
URRDLLURUULDDLLLDR
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted