RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00571

Knjige

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Tin is a very special boy. He doesn’t like a lot of things, for example he doesn’t like Barcelona, getting
defeated in video games or any sort of mess...
Today he is visiting his friend Ante to once and for all decide who is the best FIFA player. The moment
he entered Ante’s apartment, he was greeted with an unpleasant surprise. Ante has two shelves on his wall
side by side. The left one contains \(n\) books about the numerous accomplishments of Barcelona stacked
on top of each other, and the right one is empty.
He didn’t mind so much that Ante was reading, in his opinion, trashy books, but what bothered him much
more was that the books were a total mess, that is, they weren’t sorted from thinnest to thickest. As
Ante is a good friend, he immediately hurried to rearrange the books to Tin’s liking. In one move he can:
• take a book from the top of some shelf in his left or right hand, if he is not holding some other
book in that hand; or
• put the book he is holding in some hand on top of some shelf.
Ante’s strong suit is football, not rearranging books, so he asks you to find some sequence of moves, that
he will then perform, so that in the end all books will be on the left shelf and sorted from thinnest to
thickest, in the order from top to bottom.

제약
입력 형식

The first line contains an integer \(n\) (\(1 \le n \le 100\)), the number of books on the left shelf.
The second line contains \(n\) integers \(d@@RISE_MATH_BLOCK_0@@i \le 1000\)) that represent the thicknesses of the books, from
top to bottom.

출력 형식

In the first line output an integer \(k\) (\(0 \le k \le 100\,000\)), the number of moves in your solution.
In the following \(k\) lines output the moves in the form INSTRUCTION HAND SHELF, where:
• INSTRUCTION is the word UZMI (Croatian for take) if Ante should take a book from some shelf, or
the word STAVI (Croatian for put) if he should put a book on some shelf
• HAND is the letter L if Ante should use his left hand, or the letter D (Croatian word for right is desno)
if he should use his right hand
• SHELF is the letter L if this move acts on the left shelf, or the letter D if it acts on the right shelf.
Your solution does not have to be of minimum possible length, but the number of moves must not exceed
100 000. It can be proven that for the given constraints a solution always exists.

예제 1
입력
3
2 3 1
출력
8
UZMI L L
STAVI L D
UZMI L L
UZMI D L
STAVI L L
UZMI L D
STAVI L L
STAVI D L
예제 2
입력
4
1 1 2 5
출력
0
설명

Clarification of the first example:
1
3
2
1
1
3
2
2
1
3
2
3
1
2
3
4
2
3
1
5
3
2
1
6
3
2
1
7
3
2
1
8
3
21

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2020/2021 Contest 3

평가 및 의견

Knjige

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Knjige

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8