File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 11from itertools import combinations
22
3- n = int (input ())
4- a = []
5- teachers = []
6- spaces = []
3+ n = int (input ()) # 복도의 크기
4+ board = [] # 복도 정보 (N x N)
5+ teachers = [] # 모든 선생님 위치 정보
6+ spaces = [] # 모든 빈 공간 위치 정보
7+
78for i in range (n ):
89 a .append (list (input ().split ()))
910 for j in range (n ):
1011 # 선생님이 존재하는 위치 저장
1112 if a [i ][j ] == 'T' :
1213 teachers .append ((i , j ))
13- # 장애물을 설치할 수 있는 위치 저장
14+ # 장애물을 설치할 수 있는 (빈 공간) 위치 저장
1415 if a [i ][j ] == 'X' :
1516 spaces .append ((i , j ))
1617
@@ -60,15 +61,19 @@ def process():
6061 return True
6162 return False
6263
63- find = False
64+ find = False # 학생이 한 명도 감지되지 않도록 설치할 수 있는지의 여부
65+
66+ # 빈 공간에서 3개를 뽑는 모든 조합을 확인
6467for data in combinations (spaces , 3 ):
68+ # 장애물들을 설치해보기
6569 for x , y in data :
6670 a [x ][y ] = 'O'
6771 # 학생이 한 명도 감지되지 않는 경우
6872 if not process ():
6973 # 원하는 경우를 발견한 것임
7074 find = True
7175 break
76+ # 설치된 장애물을 다시 없애기
7277 for x , y in data :
7378 a [x ][y ] = 'X'
7479
You can’t perform that action at this time.
0 commit comments