File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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) )
You can’t perform that action at this time.
0 commit comments