File tree Expand file tree Collapse file tree 2 files changed +19
-18
lines changed
Expand file tree Collapse file tree 2 files changed +19
-18
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 52,480 KB, 시간: 63 ms, 코드길이: 621 Bytes
7+ 메모리: 53,760 KB, 시간: 59 ms, 코드길이: 574 Bytes
88
99### 제출 일자
1010
11- 2025-05-12 07:54
11+ 2025-05-24 11:30
1212
1313
1414
Original file line number Diff line number Diff line change 11T = int (input ())
22
3- for t in range (1 , T + 1 ):
3+ for tc in range (1 , T + 1 ):
44 N = int (input ())
5- snail = [[0 ] * N for _ in range (N )]
6-
7- dx = [0 , 1 , 0 , - 1 ]
8- dy = [1 , 0 , - 1 , 0 ]
9-
5+
6+ nums = [[0 ] * N for _ in range (N )]
7+
108 x , y = 0 , 0
119 direction = 0
12-
13- for num in range (1 , N * N + 1 ):
14- snail [x ][y ] = num
15-
10+
11+ dx = [0 , 1 , 0 , - 1 ]
12+ dy = [1 , 0 , - 1 , 0 ]
13+
14+ for i in range (1 , N * N + 1 ):
15+ nums [x ][y ] = i
16+
1617 nx = x + dx [direction ]
1718 ny = y + dy [direction ]
18-
19- if nx < 0 or nx >= N or ny < 0 or ny >= N or snail [nx ][ny ] != 0 :
19+
20+ if nx < 0 or nx >= N or ny < 0 or ny >= N or nums [nx ][ny ] != 0 :
2021 direction = (direction + 1 ) % 4
2122 nx = x + dx [direction ]
2223 ny = y + dy [direction ]
23-
24+
2425 x , y = nx , ny
25-
26- print (f"#{ t } " )
27- for row in snail :
26+
27+ print (f"#{ tc } " )
28+ for row in nums :
2829 print (* row )
You can’t perform that action at this time.
0 commit comments