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

6875번 - Bananas 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB17121090.909%

문제

The term “code monkey” is sometimes used to refer to a programmer who doesn't know much about programming. This is unfair to monkeys, because contrary to popular belief, monkeys are quite smart. They have just been misunderstood. This may be because monkeys do not speak English, but only monkey language. Your job is to help humans and monkeys understand each other by writing a monkey language dictionary. For each word that is typed in, your program must determine whether it is a valid monkey language word.

Unlike in English, spelling in monkey language is very simple. Every word in monkey language satisfies the following rules, and every word satisfying the following rules is a monkey language word.

  1. A monkey language word is a special type of word called an A-word, which may be optionally followed by the letter N and a monkey language word.
  2. An A-word is either only the single letter A, or the letter B followed by a monkey language word followed by the letter S.

Here are some examples:The word “A”' is a monkey language word because it is an A-word.

The word “ANA” is a monkey language word because it is the A-word “A” followed by the letter N and the monkey language word “A”.

The word “ANANA” is a monkey language word because it is the A-word “A” followed by the letter N and the monkey language word “ANA”.

The word “BANANAS” is a monkey language word because it is an A-word, since it is the letter B followed by the monkey language word “ANANA” followed by the letter S.

Write a program which accepts words, one word on each line, and for each word prints YES if the word is a monkey language word, and NO if the word is not a monkey language word. The input word “X” indicates the program should terminate, and there is no output for word “X” (even though it is not a monkey word).

입력

출력

제한

예제 입력 1

A
ANA
ANANA
BANANAS
BANANA
X

예제 출력 1

YES
YES
YES
YES
NO

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2005 > CCC 2005 Junior Division 5번

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

출처

대학교 대회

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

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