ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Неотсортированные > задача:


Reverse permutation

Задачи раздела

• Sum less than N
• Sum of N numbers
• The N Queens Problem
• Subsets
• Maximum Sum 2
• Gifts of Santa Claus
• Rectangles on a plane
• Permutations
• Reverse permutation
• Nameplates
• Adjacency matrix to edges list
• Edges list to Adjacency matrix
• Cities and roads
• Cycle detection
• Diameter of graph
• Divisors count
• GCD of ones

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 1000/1000/1000/1000 мс. Лимит памяти 65000/65000/65000/65000 Кб.

Problem description

A permutation is any sequence of numbers from 1 to N, σ=(σ1, σ2, ..., σn), where σiσj and 1 ≤ σi ≤ N, σ(i) = σi.

Product of permutations is calculated according to the next rule:
σ * π = (σ(1)), π(σ(2)), ..., π(σ(n))) = (π(σ1), π(σ2), ..., π(σn)).

Let permutation ε = (1, 2, ..., n). Then reverse permutation σ-1 to permutation σ is such a permutation that σ * σ-1 = ε.

Your task is to find a reverse permutation to given one.

Input

There is a single integer N on the first line (0 < N <= 20000) and N integers on the second line of input.

Output

Write reverse permutation.

Example

stdin stdout

3
2 3 1

3 1 2

Для отправки решений необходимо выполнить вход.

www.contester.ru