Status:  Past  Start:  20141004 12:30:00  End:  20141004 16:30:00 
The 2014 ACMICPC Caribbean National Contests (Real contest)
Problem
2979  Another Sorting Problem
Created by  Yonny Mondelo Hernández 
Added by  ymondelo20 (20140717) 
Limits 
Total Time: 60000 MS

Test Time:
2000 MS
Memory: 62 MB  Output: 64 MB  Size:
14 KB

Enabled languages  
Available in 
Description
 First, pick any number which is not in their corresponding position.
 Then, move this number into its corresponding position. Another number may be occupying this location, so you must also move this number to its correct position. Repeat this step while possible.
 Finally, repeat from the first step while possible.
Once these steps finish, the sequence will be ordered. You wish to know the amount of affected numbers during this sorting procedure. A number is considered affected if their initial position is distinct to their final position.
 First, pick any number which is not in their corresponding position.
 Then, move this number into its corresponding position. Another number may be occupying this location, so you must also move this number to its correct position. Repeat this step while possible.
 Finally, repeat from the first step while possible.
Once these steps finish, the sequence will be ordered. You wish to know the amount of affected numbers during this sorting procedure. A number is considered affected if their initial position is distinct to their final position.
 First, pick any number which is not in their corresponding position.
 Then, move this number into its corresponding position. Another number may be occupying this location, so you must also move this number to its correct position. Repeat this step while possible.
 Finally, repeat from the first step while possible.
Once these steps finish, the sequence will be ordered. You wish to know the amount of affected numbers during this sorting procedure. A number is considered affected if their initial position is distinct to their final position.
Input specification
 The first line contains an integer number N (1 <= N <= 50), the number of integers in the sequence.
 The second line contains N spaceseparated integer numbers, a permutation of the numbers between 1 and N.
 The first line contains an integer number N (1 <= N <= 50), the number of integers in the sequence.
 The second line contains N spaceseparated integer numbers, a permutation of the numbers between 1 and N.
 The first line contains an integer number N (1 <= N <= 50), the number of integers in the sequence.
 The second line contains N spaceseparated integer numbers, a permutation of the numbers between 1 and N.
Output specification
 The first line contains an integer number N (1 <= N <= 50), the number of integers in the sequence.
 The second line contains N spaceseparated integer numbers, a permutation of the numbers between 1 and N.
Sample input
3
1
1
5
2 3 1 5 4
9
3 2 1 5 4 7 8 6 9
Sample output
0
5
7