All submissions for this problem are available.
Rohan is an animal lover and loves specially dogs . He takes them daily on morning and evening walk altogether but in a specific order. Whenever someone asks him the names of the dogs, he tells the names of the dogs but the problem is that the dogs are never in order and keep on shifting their places.
Let’s assume that he has N number of dogs and each one has their unique integer ID number. Rohan wants his dogs to stand in their ordering, represented by the contents of an array D[1...N], where D[j] gives the ID number of the jth dog in the ordering. But every time when he tries to tell the name of the dogs, one of the dogs move to a new position in the lineup. More precisely,a dog steps away from the line,with the remaining dogs shifting over to close the resulting gaps in the lineup.
On the way back to home from evening walk with dogs. Rohan had met with 5 people. As he comes back to his home, he is muddled about the sequence of dogs. Now you have to help him to find out that sequence.
- 1 line of input contains N. the number of dogs.
- Now there will be N cases, each case represents one order of the dogs.
- The N lines of each case consists of N id's.
- The correct original order.
- 1 ≤ N ≤ 20,000
- 1 ≤ ID ≤ 99,99,999
Input: 5 10 20 30 40 50 20 10 30 40 50 30 10 20 40 50 40 10 20 30 50 50 10 20 30 40 Output: 10 20 30 40 50
|Time Limit:||1 - 10 sec|
|Source Limit:||50000 Bytes|
Fetching successful submissions