6750번: Rotating letters백준/문제2024. 9. 10. 11:21
Table of Contents
문제 출처 : https://www.acmicpc.net/problem/6750
언어 : Kotlin
문제 설명 :
An artist wants to construct a sign whose letters will rotate freely in the breeze. In order to do this, she must only use letters that are not changed by rotation of 180 degrees: I, O, S, H, Z, X, and N.
Write a program that reads a word and determines whether the word can be used on the sign.
입력 :
The input will consist of one word, all in uppercase letters, with no spaces. The maximum length of the word will be 30 letters, and the word will have at least one letter in it.
출력 :
Output YES if the input word can be used on the sign; otherwise, output NO
제한 사항 :
- 시간 제한 : 1초
- 메모리 제한 : 128MB
입출력 예 :
입력 | 출력 |
SHINS | YES |
풀이 :
import java.io.BufferedWriter
import java.io.OutputStreamWriter
fun main() = with(System.`in`.bufferedReader()) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
var result = true
val pattern = arrayOf('I', 'O', 'S', 'H', 'Z', 'X', 'N')
readLine().let { str ->
val cnt = str.filter { c ->
pattern.any { it == c }
}.length
if (str.length != cnt) result = false
}
bw.write(if (result) "YES" else "NO")
bw.flush()
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
29701번: 모스 부호 (1) | 2024.09.10 |
---|---|
29700번: 우당탕탕 영화예매 (3) | 2024.09.10 |
14455번: Don't Be Last! (1) | 2024.09.09 |
12787번: 지금 밥이 문제냐 (0) | 2024.09.09 |
30458번: 팰린드롬 애너그램 (0) | 2024.09.06 |
@스몰스테핑 :: 작은 발걸음
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!