# k = int(input())
# pair = int(input())
#
# num=[]
# checkPoint = [0]* (k+1)
#
# c = 0
#
# def travel(a, v):
# # for i in num[v][k]:
# # # for j in num[v][v]:
# # # if j not in checkPoint:
# # # checkPoint[i] = 1
# # # travel(num, j, checkPoint)
# for i in range(1, v):
# if num[a][i] == 1:
# num[a][i] = 0
# num[i][a] = 0
# checkPoint[i] = 1
# travel(i, v)
#
# for i in range(k+5):
# v = []
# for j in range(k+5):
# v.append(0)
# num.append(v)
#
# for i in range(pair):
# v = input().split()
# vx = int(v[0])
# vy = int(v[1])
#
# num[vx][vy] += 1
# num[vy][vx] += 1
# #
# # for i in range(1, pair+2):
# # for j in range(1, pair+2):
# # print(num[i][j], end=' ')
# # print()
#
# travel(1, k+2)
# # print(checkPoint)
# count =0
#
# for i in range(len(checkPoint)):
# if checkPoint[i] == 1:
# count+=1
#
# print(count-1)
k = int(input())
pair = int(input())
num=[]
num2=[[0]*(k+1) for _ in range(k+1)]
check = [[0]*(k+1) for _ in range(k+1)]
def compare(a, b, c):
for i in range(1, b):
if num2[a][i] == 1:
num2[a][i] = 0
check[c][i] = 1
compare(i, b, c)
def init(a, b):
for i in range(a, b):
for j in range(a, b):
num2[i][j] = num[i][j]
for i in range(k+2):
v = []
for j in range(k+2):
v.append(0)
num.append(v)
for i in range(pair):
v = input().split()
vx = int(v[0])
vy = int(v[1])
num[vx][vy] = 1
for i in range(1, k+1):
for j in range(1, k+1):
num2[i][j] = num[i][j]
print(num2[i][j], end=' ')
print()
for i in range(1, k+1):
compare(1, k+1, i)
init(1, k+1)
print()
print()
for i in range(1, k+1):
for j in range(1, k+1):
print(check[i][j], end=' ')
print()
top of page
기능을 테스트하려면 라이브 사이트로 이동하세요.
220210
220210
댓글 0개
좋아요
댓글(0)
bottom of page