Logo
(追記) (追記ここまで)

31895번 - Toy Train Tracks 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB30161551.724%

문제

Every little child, and quite a number of adults, are fascinated by toy trains. From a toddler’s choo-choo train to a hobbyist’s elaborate model railroad filling an entire basement, they are a profitable business. The Toy Train Tracks Construction Company (TTTCC) manufactures train tracks for all ages and skill levels. To keep their existing customers busy and maybe attract some new ones, the TTTCC has recently started publishing maps for how to connect their train tracks into elaborate layouts. Usually, this starts with a designer coming up with an interesting track layout, and then publishing both the layout and the required number of different track segments (say, curves and straight parts) needed to construct it. But the TTTCC has recently learned that many customers are looking for the reverse: they already have train track segments lying around (maybe found in grandma’s attic), and would like to use them to create a large train course. How difficult might that be?

To study the feasibility of automating the layout-creation process, TTTCC is interested in constructing train courses using two different shapes: straight line segments, and 90ドル$-degree turns (see Figure 1).

Figure 1: A straight track segment and a curved track segment.

Valid layouts are created by placing these shapes on a square grid, with each track piece taking up exactly one grid cell. Both types of pieces can be rotated in 90ドル$-degree increments. A “proper” train track needs to be connected, and should form a single closed loop. Given a set of straight and curved track segments, what is the longest closed loop that one can construct?

Figure 2: A sample track using four straight track segments and twelve curves. This corresponds to Sample Output 1.

입력

The input consists of a single line containing two integers $s$ and $c,ドル the number of straight and curved track segments available, respectively (0ドル≤s≤10^5,ドル 4ドル≤c≤10^5$).

출력

Output a train loop using at most $s$ straight segments and $c$ curved segments, that has the longest length (in number of track segments used) under this restriction. The loop must be closed and cannot intersect itself. If there are multiple loops of maximal length, any one of them will be accepted.

If the loop is of length $n,ドル then print a single string of length $n,ドル where the characters represent the loop’s segments as encountered in a single traversal. The character ‘S‘ stands for a straight-line segment, ‘L‘ for a curved segment that is a left turn, and ‘R’ for a curved segment that is a right turn.

제한

예제 입력 1

4 12

예제 출력 1

LSRLLRLSLSRLLSRL

예제 입력 2

1 5

예제 출력 2

LLLL

힌트

출처

ICPC > World Finals > ICPC World Finals 2022 U번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /