Skip to content

Commit 35ec3d5

Browse files
authored
Update 6.py
1 parent 5d9098d commit 35ec3d5

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

13/6.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,47 @@
66
spaces = [] # 모든 빈 공간 위치 정보
77

88
for i in range(n):
9-
a.append(list(input().split()))
9+
board.append(list(input().split()))
1010
for j in range(n):
1111
# 선생님이 존재하는 위치 저장
12-
if a[i][j] == 'T':
12+
if board[i][j] == 'T':
1313
teachers.append((i, j))
1414
# 장애물을 설치할 수 있는 (빈 공간) 위치 저장
15-
if a[i][j] == 'X':
15+
if board[i][j] == 'X':
1616
spaces.append((i, j))
1717

1818
# 특정 방향으로 감시를 진행 (학생 발견: True, 학생 미발견: False)
1919
def watch(x, y, direction):
2020
# 왼쪽 방향으로 감시
2121
if direction == 0:
2222
while y >= 0:
23-
if a[x][y] == 'S': # 학생이 있는 경우
23+
if board[x][y] == 'S': # 학생이 있는 경우
2424
return True
25-
if a[x][y] == 'O': # 장애물이 있는 경우
25+
if board[x][y] == 'O': # 장애물이 있는 경우
2626
return False
2727
y -= 1
2828
# 오른쪽 방향으로 감시
2929
if direction == 1:
3030
while y < n:
31-
if a[x][y] == 'S': # 학생이 있는 경우
31+
if board[x][y] == 'S': # 학생이 있는 경우
3232
return True
33-
if a[x][y] == 'O': # 장애물이 있는 경우
33+
if board[x][y] == 'O': # 장애물이 있는 경우
3434
return False
3535
y += 1
3636
# 위쪽 방향으로 감시
3737
if direction == 2:
3838
while x >= 0:
39-
if a[x][y] == 'S': # 학생이 있는 경우
39+
if board[x][y] == 'S': # 학생이 있는 경우
4040
return True
41-
if a[x][y] == 'O': # 장애물이 있는 경우
41+
if board[x][y] == 'O': # 장애물이 있는 경우
4242
return False
4343
x -= 1
4444
# 아래쪽 방향으로 감시
4545
if direction == 3:
4646
while x < n:
47-
if a[x][y] == 'S': # 학생이 있는 경우
47+
if board[x][y] == 'S': # 학생이 있는 경우
4848
return True
49-
if a[x][y] == 'O': # 장애물이 있는 경우
49+
if board[x][y] == 'O': # 장애물이 있는 경우
5050
return False
5151
x += 1
5252
return False
@@ -67,15 +67,15 @@ def process():
6767
for data in combinations(spaces, 3):
6868
# 장애물들을 설치해보기
6969
for x, y in data:
70-
a[x][y] = 'O'
70+
board[x][y] = 'O'
7171
# 학생이 한 명도 감지되지 않는 경우
7272
if not process():
7373
# 원하는 경우를 발견한 것임
7474
find = True
7575
break
7676
# 설치된 장애물을 다시 없애기
7777
for x, y in data:
78-
a[x][y] = 'X'
78+
board[x][y] = 'X'
7979

8080
if find:
8181
print('YES')

0 commit comments

Comments
 (0)