0
0

【配列に対しての複雑な処理】集団行動

Posted at

N,Q = map(int,input().split())
A = [a for a in range(1,N+1)]
for i in range(1,Q+1):
    tmp = []
    tmp = input().split()
    if tmp[0] == 'reverse':
        A.reverse()
    elif tmp[0] == 'swap':
        num = A[tmp[1]+1]
        A[tmp[1]+1] = A[tmp[2]+1]
        A[tmp[2]+1] = num
    elif tmp[0] == 'resize':
        c = int(tmp[1])
        A = A[:c]
print(*A,sep="\n")

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0