1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

paizaラーニング

Posted at

私の解答

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)
1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?