[코드업_기초100제] #1097 문제


#1097 문제

P1097 : [기초-종합+배열] 바둑알 십자 뒤집기

# 내 답안

# 19 x 19 리스트 만들기
m = 19
mat = []
for i in range(m) :
    mat.append(input().split())

#  n번의 십자 diverse
n = int(input())
div_mat = []
for j in range(n) :
    div_mat.append(input().split())

# x축을 0 -> 1 
for i in range(2) :
    for k in range(19) :
        if mat[int(div_mat[i][0])-1][k] == '0' :
            mat[int(div_mat[i][0])-1][k] = '1'
        elif mat[int(div_mat[i][0])-1][k] == '1' :
             mat[int(div_mat[i][0])-1][k] = '0'


# y축을 0 -> 1 
for i in range(2) :
    for k in range(19) :
        if mat[k][int(div_mat[i][1])-1] == '0' :
            mat[k][int(div_mat[i][1])-1] = '1'
        elif mat[k][int(div_mat[i][1])-1] == '1' :
            mat[k][int(div_mat[i][1])-1] = '0'

# 바꾼 matrix 꺼내기
for i in range(19) :
    for j in range(19) :
        print(int(mat[i][j]), end = ' ')
    print('')
# 코드업 
m=[]
for i in range(20) :
    m.append([])
    for j in range(20) :
        m[i].append(0)

for i in range(19) :
    a=input().split()
    for j in range(19) :
        m[i+1][j+1]=int(a[j])
    
n=int(input())

for i in range(n) :
    x,y=input().split()
    for j in range(1, 20) :
        
        if m[j][int(y)]==0 :
            m[j][int(y)]=1
        else :
            m[j][int(y)]=0

        if m[int(x)][j]==0 :
            m[int(x)][j]=1
        else :
            m[int(x)][j]=0

for i in range(1, 20) :
    for j in range(1, 20) :
        print(m[i][j], end=' ')
    print()





© 2018. by statssy

Powered by statssy