본문 바로가기
IT관련 정보

[S/W 문제해결 기본] 1일차 - View 파이썬 코드

by mainspring 2021. 4. 2.

한강 조망권 문제 입니다. 

 




T = 10
for test_case in range(1, T + 1):
test_length = int(input())
power = list(map(int,input().split()))
sample = []
lenth = len(power)
num = 0
for i in range(0,lenth) :
line = []
num = power[i]
for _ in range(0,num) :
line.append(1)
for _ in range(num,255):
line.append(0)
sample.append(line)
check = 0
# 0 0 1 0 0 0
# 0 0 1 0 0 0
# 0 0 1 1 0 0
# 0 0 1 1 0 0
# 0 0 1 1 0 0
# y 가 행이다
# x 가 층수임.
for x in range(0,255) :
found = 0
find = 0
for y in range(0,test_length) :
if sample[y][x] == 1 and sample[y-1][x] == 0 and sample[y-2][x] ==0 and sample[y+1][x] == 0 and sample[y+2][x] == 0 :
check = 1 + check
# print ("1번걸림",end = '')
else :
#print("5번걸림", end= '')
found = 0
find = 0
print("#"+str(test_case),check)

 

댓글