Inflearn Community Q&A
이건 왜 안되는걸까요?
Written on
·
307
0
import sys
sys.stdin=open("input.txt", "rt")
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
for i in a:
i.insert(0, 0)
i.append(0)
b = [0]*(n+2)
a.insert(0, b)
a.append(b)
dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]
def check(x, y):
for i in range(4):
nx = x+dx[i]
ny = x+dy[i]
if a[x][y] <= a[nx][ny]:
return False
return True
res = 0
for x in range(1, n+1):
for y in range(1, n+1):
if check(x, y):
res += 1
print(res)
코드는 위와 같고요,
리스트 a는 잘 출력되는것으로 보아,
제가만든 check 함수의 설정에서 잘못된것 같은데, 논리상 어떤점 때문에 잘못 된 건지 모르겠습니다.
코테 준비 같이 해요! python
Quiz
71% of people got it wrong. Give it a try!
회문 문자열(Palindrome)의 정의는 무엇일까요?
모든 문자가 동일한 문자열
앞에서부터 읽으나 뒤에서부터 읽으나 같은 문자열
알파벳과 숫자가 섞여 있는 문자열
특정 패턴이 반복되는 문자열





