백준 [ALGORITHM] - 카드1 (2161)

2024. 1. 30. 14:51코딩/백준 [ALGORITHM]

반응형
from queue import Queue
N = int(input())

lst = [i + 1 for i in range(N)]
collect = []

for i in range(len(lst)):
    if len(lst) != 1:
        tmp1 = lst.pop(0)
        collect.append(tmp1)

        tmp = lst[0]
        lst.pop(0)
        lst.append(tmp)

    else:
        if len(" ".join(map(str, collect))+  " ".join(map(str, lst))) == 1:
            print("".join(map(str, lst)))
            break
        print(" ".join(map(str, collect)),  " ".join(map(str, lst)))
반응형