Skip to content

Commit fa39ca6

Browse files
committed
[Gold IV] Title: 별 찍기 - 11, Time: 48 ms, Memory: 116384 KB -BaekjoonHub
1 parent f53ea56 commit fa39ca6

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

백준/Gold/2448. 별 찍기 - 11/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
### 성능 요약
66

7-
메모리: 19568 KB, 시간: 268 ms
7+
메모리: 116384 KB, 시간: 48 ms
88

99
### 분류
1010

1111
재귀
1212

1313
### 제출 일자
1414

15-
2025년 6월 26일 21:47:31
15+
2025년 6월 26일 21:49:14
1616

1717
### 문제 설명
1818

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Foundation
2+
3+
let n = Int(readLine()!)!
4+
let rows = n
5+
let cols = 2 * n - 1
6+
let totalCols = cols + 1
7+
8+
var buf = [UInt8](repeating: 32, count: rows * totalCols)
9+
for r in 0..<rows { buf[r * totalCols + cols] = 10 }
10+
11+
func draw(_ n: Int, _ r: Int, _ c: Int) {
12+
if n == 3 {
13+
buf[(r + 0) * totalCols + (c + 2)] = 42
14+
buf[(r + 1) * totalCols + (c + 1)] = 42
15+
buf[(r + 1) * totalCols + (c + 3)] = 42
16+
for i in 0..<5 { buf[(r + 2) * totalCols + (c + i)] = 42 }
17+
return
18+
}
19+
20+
let half = n / 2
21+
draw(half, r, c + half)
22+
draw(half, r + half, c)
23+
draw(half, r + half, c + half * 2)
24+
}
25+
26+
draw(n, 0, 0)
27+
FileHandle.standardOutput.write(Data(buf))

0 commit comments

Comments
 (0)