시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 2067 554 398 27.969%

문제

상근이는 우리나라에서 가장 유명한 놀이 공원을 운영하고 있다. 이 놀이 공원은 야외에 있고, 다양한 롤러코스터가 많이 있다.

어느 날 벤치에 앉아있던 상근이는 커다란 황금을 발견한 기분이 들었다. 자신의 눈 앞에 보이는 이 부지를 구매해서 롤러코스터를 만든다면, 세상에서 가장 재미있는 롤러코스터를 만들 수 있다고 생각했다.

이 부지는 직사각형 모양이고, 상근이는 R행 C열의 표 모양으로 나누었다. 롤러코스터는 가장 왼쪽 위 칸에서 시작할 것이고, 가장 오른쪽 아래 칸에서 도착할 것이다. 롤러코스터는 현재 있는 칸과 위, 아래, 왼쪽, 오른쪽으로 인접한 칸으로 이동할 수 있다. 각 칸은 한 번 방문할 수 있고, 방문하지 않은 칸이 있어도 된다.

각 칸에는 그 칸을 지나갈 때, 탑승자가 얻을 수 있는 기쁨을 나타낸 숫자가 적혀있다. 롤러코스터를 탄 사람이 얻을 수 있는 기쁨은 지나간 칸의 기쁨의 합이다. 가장 큰 기쁨을 주는 롤러코스터는 어떻게 움직여야 하는지를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 R과 C가 주어진다. (2 ≤ R, C ≤ 1000) 둘째 줄부터 R개 줄에는 각 칸을 지나갈 때 얻을 수 있는 기쁨이 주어진다. 이 값은 1000보다 작은 양의 정수이다.

출력

첫째 줄에 가장 가장 큰 기쁨을 주는 롤러코스터는 가장 왼쪽 위 칸부터 가장 오른쪽 아래 칸으로 어떻게 움직이면 되는지를 출력한다. 위는 U, 오른쪽은 R, 왼쪽은 L, 아래는 D로 출력한다. 정답은 여러 가지 일 수도 있다.

예제 입력 1

3 3
5 1 3
2 4 8
1 1 2

예제 출력 1

RRDLLDRR
W3sicHJvYmxlbV9pZCI6IjI4NzMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI4NjRcdWI3ZWNcdWNmNTRcdWMyYTRcdWQxMz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GFpbnMgQyBwb3NpdGl2ZSBpbnRlZ2VycyBzbWFsbGVyIHRoYW4gMTAwMCwgc3BlY2lmeWluZyB0aGUgYW11c2VtZW50IHZhbHVlcyBvZiB0aGUgcmVzcGVjdGl2ZSB0YWJsZSBjZWxscy48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5UaGUgZmlyc3QgYW5kIG9ubHkgbGluZSBvZiBvdXRwdXQgbXVzdCBjb250YWluIGEgc2VxdWVuY2Ugb2YgbGV0dGVycyB3aXRoIG5vIGJsYW5rcy4gVGhlIGxldHRlcnMgc3BlY2lmeSB0aGUgc2VxdWVuY2Ugb2YgZGlyZWN0aW9ucyB0aGF0IHRoZSBjb2FzdGVyIGZvbGxvd3MsIHN0YXJ0aW5nIGZyb20gdGhlIHVwcGVyIGxlZnQgYW5kIGVuZGluZyBhdCB0aGUgbG93ZXIgcmlnaHQgY29ybmVyLiBUaGUgZGlyZWN0aW9ucyB1cCwgcmlnaHQsIGRvd24sIGxlZnQgYXJlIG1hcmtlZCBieSBsZXR0ZXJzICZsc3F1bztVJnJzcXVvOywgJmxzcXVvO1ImcnNxdW87LCAmbHNxdW87RCZyc3F1bzssICZsc3F1bztMJnJzcXVvOywgcmVzcGVjdGl2ZWx5LiZuYnNwOzxcL3A+XHJcblxyXG48cD5Ob3RlOiBUaGUgc29sdXRpb24gaXNuJnJzcXVvO3QgZ3VhcmFudGVlZCB0byBiZSB1bmlxdWUuJm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

Contest > Croatian Open Competition in Informatics > COCI 2010/2011 > Contest #2 5번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: kjp4155