26 lines
635 B
Swift
26 lines
635 B
Swift
if let N = Int(readLine() ?? "0"),
|
|
let input = readLine(),
|
|
let A: [Int] = input.split(separator: " ").compactMap({Int($0)}) as? [Int],
|
|
A.count == N
|
|
{
|
|
let mapA = A.enumerated().map({ (i, v) in
|
|
return (value: v, index: i)
|
|
})
|
|
|
|
let sortedA = mapA.sorted(by: {
|
|
if $0.value == $1.value {
|
|
return $0.index < $1.index
|
|
}
|
|
return $0.value < $1.value
|
|
})
|
|
|
|
var P: [Int] = Array(repeating: 0, count: N)
|
|
for (sortedIndex, element) in sortedA.enumerated() {
|
|
P[element.index] = sortedIndex
|
|
}
|
|
|
|
for p in P {
|
|
print(p, terminator: " ")
|
|
}
|
|
}
|