회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
파이썬 18428번 질문있습니다
18428번 - 감시 피하기
skatn3
3년 전
0
3
X T T
S X T
S X T
의 경우에 T가 중복될 때 문제가 생깁니다. 혹시 도움 주실수 있으신가요?
from itertools import combinations def check_r(graph,tx,ty): #동쪽 체크 if ty<len(graph[0]) and ty >=0: if graph[tx][ty] == 'S': return False else: if graph[tx][ty] == 'O': return True # 벽 먼저 만나면 이상 없음 check_r(graph,tx,ty+1) return True # 무사히 동쪽 끝 까지 가면 이상 없음 def check_l(graph,tx,ty): #서쪽 체크 if ty<len(graph[0]) and ty >=0: if graph[tx][ty] == 'S': return False else: if graph[tx][ty] == 'O': print(tx,ty,end = ' ') print() print('서쪽 벽') return True check_l(graph,tx,ty-1) else: print('서쪽 끝') return True # 무사히 서쪽 끝 까지 가면 def check_d(graph,tx,ty): #남쪽 체크 if tx<len(graph) and tx >=0: if graph[tx][ty] == 'S': return False else: if graph[tx][ty] == 'O': return True check_d(graph,tx+1,ty) return True # 무사히 남쪽 끝 까지 가면 def check_u(graph,tx,ty): #북쪽 체크 if tx<len(graph) and tx >=0: if graph[tx][ty] == 'S': return False else: if graph[tx][ty] == 'O': return True check_u(graph,tx-1,ty) return True # 무사히 북쪽 끝 까지 가면 def solve(pos_wall,graph): for pos in pos_wall: t_cnt = len(teacher) # 선생 수 print(t_cnt) # 벽 설치 for a,b in pos: graph[a][b] = 'O' print(graph) # 선생님 좌표 for x,y in teacher: if check_r(graph,x,y+1) and check_l(graph,x,y-1) and check_d(graph,x+1,y) and check_u(graph,x-1,y) == True : t_cnt -=1 print(t_cnt) if t_cnt == 0: return 'YES' # 벽 제거 for a,b in pos: graph[a][b] = 'X' return 'NO' N = int(input()) graph = [] wall = [] teacher = [] for i in range(N): a=list(input().split()) graph.append(a) for j in range(len(a)): if a[j] == 'X': wall.append((i,j)) if a[j] == 'T': teacher.append((i,j)) pos_wall=list(combinations(wall,3)) print(solve(pos_wall,graph))
댓글을 작성하려면
로그인
해야 합니다.
skatn3 3년 전
3
X T T
S X T
S X T
의 경우에 T가 중복될 때 문제가 생깁니다. 혹시 도움 주실수 있으신가요?