MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon/Python

#10813 ๊ณต ๋ฐ”๊พธ๊ธฐ -python

HYEJU01 2024. 4. 15. 02:22

 

N,M =map(int,input().split())
x,y = 0,0
a,tmp=[],0

for x in range(N):
    a.append((x+1))

for y in range(M) :
    i,j = map(int,input().split())
    tmp = a[j-1]
    a[j-1] = a[i-1]
    a[i-1] = tmp

print(*a, sep=" ")

 

 

๊ฐ’์„ ๋ฐ”๊ตฌ๋‹ˆ ๋ฒˆํ˜ธ์™€ ๋™์ผํ•˜๊ฒŒ ์ดˆ๊ธฐํ™” a.append((x+1))

tmp ๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐ’์„ ๋ฐ”๊ฟ”์ค€๋‹ค.

 

 

<< ์‚ฌ์šฉ๋œ ํ•จ์ˆ˜ >>

๐Ÿ”” map (์ ์šฉ์‹œํ‚ฌ ํ•จ์ˆ˜,  ์ ์šฉํ•  ๋ฐ˜๋ณต๊ฐ€๋Šฅํ•œ์ž๋ฃŒํ˜• ) :  ๊ฐ’์„ ์ผ๊ด„๋กœ ๋ณ€ํ™˜

๐Ÿ””  input().split()  : ๊ณต๋ฐฑ์„ ๊ธฐ์ค€์œผ๋กœ ๋ถ„๋ฆฌํ•˜์—ฌ ๊ฐ’์„ ๋ฐ›์Œ

๐Ÿ”” ๋ฆฌ์ŠคํŠธ๋ช….append() : ๋ฆฌ์ŠคํŠธ์— ๊ฐ’ ์ถ”๊ฐ€ํ•˜๊ธฐ

๐Ÿ”” print(*๋ฆฌ์ŠคํŠธ๋ช…, sep=" ")  : ๋ฆฌ์ŠคํŠธ ์ถœ๋ ฅ ์‹œ ๋Œ€๊ด„ํ˜ธ ์—†์ด ์ถœ๋ ฅํ•˜๋Š” ๋ฐฉ๋ฒ•.