私の解答
a, b, n = map(int, input().split())
li = [int(x) for x in input().split()]
li[a-1], li[b-1] = li[b-1], li[a-1]
for i in range(n):
print(li[i])
私の解答は解答例2に近い感じでした。
解答例1
values = input().split()
A = int(values[0])
B = int(values[1])
N = int(values[2])
a = [0] * N
values = input().split()
for i in range(N):
a[i] = int(values[i])
tmp = a[A - 1]A, B, N = map(int, input().split())
a = [int(x) for x in input().split()]
a[A-1], a[B-1] = a[B-1], a[A-1]
for ele in a:
print(ele)
a[A - 1] = a[B - 1]
a[B - 1] = tmp
for ele in a:
print(ele)
解答例2
A, B, N = map(int, input().split())
a = [int(x) for x in input().split()]
a[A-1], a[B-1] = a[B-1], a[A-1]
for ele in a:
print(ele)