chyam

[백준] 10811,python - 바구니 뒤집기 본문

백준

[백준] 10811,python - 바구니 뒤집기

chyam_eun 2025. 8. 8. 11:05

https://www.acmicpc.net/problem/10811

n,m = list(map(int,input().split()))
li = [_ for _ in range(1,n+1)]

for _ in range(m):
    i,j = list(map(int,input().split()))
    fir = i - 1
    end = j - 1
    while fir < end:
        li[fir],li[end] = li[end],li[fir] # 앞 뒤 바꿔줌 
        fir += 1
        end -= 1
        
for s in li:  
    print(s,end= ' ')