python-algorithm

백준 10804 카드 역배치

무적김두칠 2021. 12. 3. 10:51

1
2
3
4
5
6
7
tmp=[i+1 for i in range(20)]
for i in range(10):
    a,b=map(int, input().split())
    a-=1
    b-=1
    tmp[a:b+1]=tmp[a:b+1][::-1]
print(*tmp)
cs

python에서 list[::-1]를 이용해서 쉽게 구현가능합니다.
https://stackoverflow.com/questions/41430791/python-list-error-1-step-on-1-slice

반응형