
코드 입력
basket_cnt, action_cnt = map(int, input().split())
# 바구니 번호대로 리스트 생성
result = [i for i in range(1, basket_cnt+1)]
for _ in range(action_cnt):
# 첫 바구니, 두번째 바구니 번호
first_basket, second_basket = map(int, input().split())
# 첫 공의 값과 두번째 공의 값
first_ball = result[first_basket-1]
second_ball = result[second_basket-1]
# 값을 서로 교환
result[first_basket-1] = second_ball
result[second_basket-1] = first_ball
🔗 [백준 Online Judge]