인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

heewon2218921's profile image
heewon2218921

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

8. Sandglass

3번이 안풀립니다

Written on

·

61

0

import sys

import copy

#sys.stdin=open("input.txt","rt")

'''

#3번이 틀림

n =int(input())

li1 = [list(map(int, input().split())) for _ in range(n)]

cpy =copy.deepcopy(li1) #깊은 카피를 사용

m=int(input())

tot=s=0

e = n

#print(cpy)

#li1 회전

for i in range(m):

li2 = list(map(int, input().split()))

print(li2)

if li2[1] == 0: #왼쪽으로 회전

for j in range(n):

if j-li2[2] < 0:

li1[li2[0]-1][j-li2[2]+n] = cpy[li2[0]-1][j]

else:

li1[li2[0]-1][j-li2[2]] = cpy[li2[0]-1][j]

if li2[1] == 1: #오른쪽으로 회전

for j in range(n):

if j+li2[2] < n:

li1[li2[0]-1][j+li2[2]] = cpy[li2[0]-1][j]

else:

li1[li2[0]-1][(j+li2[2])%n] = cpy[li2[0]-1][j]

#print(li1)

for i in range(n):

for j in range(s,e):

tot += li1[i][j]

if i < n//2:

s+=1

e-=1

else:

s-=1

e+=1

print(tot)

 

다음과 같이 풀때, 1245번은 정답이 뜨는데 3번만 틀린ㄴ값으로 뜹니다..

뭐가 틀린지 모르겠습니다..알려주세요..

python코딩-테스트

Answer

This question is waiting for answers
Be the first to answer!
heewon2218921's profile image
heewon2218921

asked

Ask a question