0
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 3 years have passed since last update.

ABC142 C - Go to School を解いた

Last updated at Posted at 2021-10-14

abc142_1.png
abc142_2.png
abc142_3.png

特に注意点はないと思う。
そのまま書けばok

abc142c.py
N = int(input())
A = list(map(int,input().split()))
memo = {}
for i in range(N):
    memo[i] = A[i]
memo = sorted(memo.items(),key=lambda x:x[1])
#print(memo)
ans = []
for a,b in memo:
    ans.append(str(a+1))

print(" ".join(ans))#141ms

新規で enumerate を導入してみた。

更に map も駆使したらすっきりした。

abc142c.py
def solv():
    N = int(input())
    A = list(map(int,input().split()))
    lis = [0]*N
    for a,b in enumerate(A):
        lis[b-1] = a+1
    print(" ".join(map(str,lis)))

solv()#74ms
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?