[SWEA] 1230 [S/W 문제해결 기본] 8일차 - 암호문3
카테고리 : Study >> Algorithm
문제 링크
나의 풀이
t = 10
for tc in range(1, t+1):
ori_length = int(input())
original = list(map(int, input().split()))
com_num = int(input())
commands = list(input().split())
result = []
for i in range(len(commands)):
if commands[i] == 'I':
x = int(commands[i+1])
y = int(commands[i+2])
s = list(map(int, commands[i+3:i+3+y]))
for j in range(len(original)):
if j == x:
for v in s:
result.append(v)
result.append(original[j])
else:
result.append(original[j])
original = result
result = []
elif commands[i] == 'D':
x = int(commands[i+1])
y = int(commands[i+2])
for j in range(len(original)):
if j == x:
if y:
y -= 1
continue
else:
result.append(original[j])
original = result
result = []
elif commands[i] == 'A':
y = int(commands[i+1])
s = list(map(int, commands[i+2:i+2+y]))
result += original
for v in s:
result.append(v)
original = result
result = []
print(f"#{tc}", end=" ")
for v in original[:10]:
print(v, end=" ")
print("")