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

10209번 - Theseus and the Minotaur 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB79554772.308%

문제

Theseus was one of the founding fathers of Athens, and a hero of strength, intelligence, and courage in his own right. While his life was not quite as troubled as Heracles’s, it was far from drama-free: his step mother tried to poison him, and his father committed suicide because he put up the wrong color of sail upon his return home from slaying the Minotaur. (A black sail was to indicate his death, and he forgot to change it to white.) Theseus is best known for slaying the Minotaur, a fabled half-man, half-bull monster, who lived inside a labyrinth in Crete whence Athenian youth were sent to be sacrificed. According to the legend, Ariadne of Crete fell in love with Theseus, and provided him with a string to avoid losing his place in the labyrinth. He attached it at the entrance and would unwind and rewind it as he proceeded through the labyrinth.

In this problem, you are to determine whether a given sequence of steps is consistent with this “string-based” approach of traversing a labyrinth, such that at the end, the entire string is rolled up again. You will be given a sequence of steps, consisting of the lowercase letters ‘l’, ‘r’, ‘u’, ‘d’, describing the four directions on a rectangular grid that Theseus walked in. For instance, if Theseus walks “urdl”, he is back where he started, but since he may have walked around a pillar, his string is not rewound.

입력

The first line is the number K of input data sets, followed by the K data sets, each of the following form:

Each data set is a single string of lowercase letters ‘l’, ‘r’, ‘u’, ‘d’, of length at most 100 characters.

출력

For each data set, output “Data Set x:” on a line by itself, where x is its number.

Then output whether the string is fully rewound by the end of the sequence, either “Yes” or “No”.

Each data set should be followed by a blank line.

제한

예제 입력 1

3
uldrurdl
uuldurudrruuddrllldd
uuuuurrrllllrdddddd

예제 출력 1

Data Set 1:
No
Data Set 2:
Yes
Data Set 3:
No

힌트

출처

University > The USC Programming Contest > Spring 2014: Greek Mythology E번

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

출처

대학교 대회

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

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