문제 출처 : https://www.acmicpc.net/problem/14175
언어 : Kotlin
문제 설명 :
Bessie and her cow friends are playing as their favorite cow superheroes. Of course, everyone knows that any self-respecting superhero needs a signal to call them to action. Bessie has drawn a special signal on a sheet of M×N paper (1≤M≤10,1≤N≤10), but this is too small, much too small! Bessie wants to amplify the signal so it is exactly K times bigger (1≤K≤10) in each direction.
The signal will consist only of the '.' and 'X' characters.
입력 :
The first line of input contains M, N, and K, separated by spaces.
The next M lines each contain a length-N string, collectively describing the picture of the signal.
출력 :
You should output KM lines, each with KN characters, giving a picture of the enlarged signal.
제한 사항 :
- 시간 제한 : 2초
- 메모리 제한 : 512MB
입출력 예 :
입력 | 출력 |
5 4 2 XXX. X..X XXX. X..X XXX. |
XXXXXX.. XXXXXX.. XX....XX XX....XX XXXXXX.. XXXXXX.. XX....XX XX....XX XXXXXX.. XXXXXX.. |
풀이 :
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
fun main() = with(BufferedReader(InputStreamReader(System.`in`))) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
val (m, n, k) = readLine().split(" ").map { it.toInt() }
repeat(m) {
val line = readLine()
val mid = line.length / 2
if (n % 2 == 0) {
val left = line.slice(0 until mid).map { "$it".repeat(k) }.joinToString("")
val right = line.slice(mid .. line.lastIndex).map { "$it".repeat(k) }.joinToString("")
repeat(k) {
bw.appendLine(left + right)
}
} else {
val left = line.slice(0 until mid).map { "$it".repeat(k) }.joinToString("")
val right = line.slice(mid + 1 .. line.lastIndex).map { "$it".repeat(k) }.joinToString("")
repeat(k) {
bw.appendLine(left + "${line[mid]}".repeat(k) + right)
}
}
}
bw.flush()
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
5637번: 가장 긴 단어 (0) | 2024.05.30 |
---|---|
15819번: 너의 핸들은 (0) | 2024.05.29 |
18198번: Basketball One-on-One (0) | 2024.05.29 |
25205번: 경로당펑크 2077 (0) | 2024.05.28 |
24510번: 시간복잡도를 배운 도도 (0) | 2024.05.28 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!