A1195 | [COCI-2010_2011-contest2]#4 LUNAPARK
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mirko has grown tired of all the books, so he decided to go to the amusement park with his friends, despite not liking roller coasters. While his friends are having the time of their lives riding the coasters, Mirko is sitting on a bench, waiting and thinking about the possible paths of the coasters.
The amusement park’s area can be represented as a table of R rows by C columns. A roller coaster has to start from the upper left corner and end at the lower right corner of the table. Each cell can be visited at most once, but not all cells need to be visited. It can continue its path from the current cell to the adjacent one above, below, to the left, or to the right of it.
Each cell has a positive integer value associated with it, specifying how amusing that cell is to visitors.
The total amusement value of the coaster is the sum of amusement values of all cells that the coaster visits. Help Mirko determine any one of the most amusing coasters (ones with the maximum sum).
The amusement park’s area can be represented as a table of R rows by C columns. A roller coaster has to start from the upper left corner and end at the lower right corner of the table. Each cell can be visited at most once, but not all cells need to be visited. It can continue its path from the current cell to the adjacent one above, below, to the left, or to the right of it.
Each cell has a positive integer value associated with it, specifying how amusing that cell is to visitors.
The total amusement value of the coaster is the sum of amusement values of all cells that the coaster visits. Help Mirko determine any one of the most amusing coasters (ones with the maximum sum).
输入格式
The first line of input contains two integers R and C (2 ≤ R, C ≤ 1000), the dimensions of the table.
Each of the next R lines contains C positive integers smaller than 1000, specifying the amusement values of the respective table cells.
Each of the next R lines contains C positive integers smaller than 1000, specifying the amusement values of the respective table cells.
输出格式
The first and only line of output must contain a sequence of letters with no blanks. The letters specify the sequence of directions that the coaster follows, starting from the upper left and ending at the lower right corner. The directions up, right, down, left are marked by letters ‘U’, ‘R’, ‘D’, ‘L’, respectively.
Note: The solution isn’t guaranteed to be unique.
Note: The solution isn’t guaranteed to be unique.
输入输出样例
输入 #1
3 3 5 1 3 2 4 8 1 1 2
输出 #1
RRDLLDRR
输入 #2
2 2 2 1 3 4
输出 #2
DR
Test cases worth 70% of total points the numbers R and C will not exceed 30.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted