check 배열을 사용해서 queue 사용해서 해본 코드
T = int(input())
for _ in range(T):
n,m = map(int,input().split())
tmp = list(map(int,input().split()))
check = [0] * n
check[m] = 1
check = deque(check)
findv = tmp[m]
tmp = deque(tmp)
cnt = 0
while tmp:
now = tmp.popleft()
checknow = check.popleft()
if all(now >= element for element in tmp):
if now == findv and checknow == 1:
print(cnt+1)
else:
cnt += 1
else:
tmp.append(now)
check.append(checknow)
https://velog.io/@0imary/python3-%EB%B0%B1%EC%A4%80-3190%EB%B2%88-%EB%B1%80
그냥 공 넣는 문제..
n,m = map(int,input().split())
basket = [0] * (n+1)
for i in range(m):
i,j,k = map(int,input().split())
for num in range(i,j+1):
basket[num] = k
for i in range(1,n+1):
print(basket[i],end=' ')
이게 맞는 코드인지는 모르겠는데 그냥 뒤집어서 [::-1] 넣음..
n, m = map(int,input().split())
basket = [i for i in range(n+1)]
for i in range(m):
s, e = map(int,input().split())
basket[s:e+1] = basket[s:e+1][::-1]
for i in range(1,n+1):
print(basket[i],end=' ')
걍 swap 하는 문제
n,m = map(int,input().split())
basket = [i for i in range(n+1)]
for _ in range(m):
i,j = map(int,input().split())
basket[i], basket[j] = basket[j], basket[i]
for i in range(1,n+1):
print(basket[i],end=' ')