본문 바로가기
problem solving

1228. [S/W 문제해결 기본] 8일차 - 암호문1

by ormgm 2019. 9. 29.

import copy

for t in range(10):

    lenn = int(input()) # 원본 암호문 길이

    text = list(map(str,input().split())) # 원본 암호문

    inst_n = int(input()) # 명령어 개수

    inst = list(map(str,input().split())) # 명령어

    x = int(inst[1]) # x의 자리에

    y = int(inst[2]) # y개의 숫자 삽입

    inst_index = 3 # 숫자

    now = 3 # 다음 반복문을 가리킴

 

    for i in range(inst_n):

        for j in range(y):

            text.insert(x,inst[inst_index]) # 숫자 추가

            x = x + 1 # 다음 자리 지정

            inst_index +=1

            now += 1

        if i < inst_n-1:

            x = int(inst[now+1])

            y = int(inst[now+2])

            now += 3

            inst_index = copy.deepcopy(now)

 

    print('#%d'%(t+1),end=' ')

    for i in range(10):

        if i < 9:

            print(text[i],end = ' ')

        else:

            print(text[i])

댓글