I can't understand Bovine Shuffle

http://www.usaco.org/index.php?page=viewproblem2&cpid=760

I can’t understand why the input of :

5
1 3 4 5 2
1234567 2222222 3333333 4444444 5555555

gives an output of :

1234567
5555555
2222222
3333333
4444444

The 1st number of the third line is the 1st number of the output
The 2nd number of the third line is the 3rd number of the output
The 3rd number of the third line is the 4th number of the output
and so on

Let me know if that helps!

With your suggestion, I coded up :

#include <fstream>
#include <vector>
#include <algorithm>
using namespace std ;

int ID[100], a[100], ans[100] ;

ifstream cin ("shuffle.in") ;
ofstream cout ("shuffle.out") ;

int main() {
	int n, test ;
	cin >> n ;
	for (int i=0; i<n; i++) {
		cin >> a[i] ;
	}
	for (int i=0; i<n; i++) {
		cin >> ID[i] ;
	}

	for (int i=0; i<n; i++) {
		ans[a[i]-1] = ID[i] ;
	}
	
	for (int i=0; i<n; i++) {
		cout << ans[i] << endl ;
	}

	return 0 ;
}

It didn’t get accepted except for the first test case! I don’t know why it doesn’t work.

Have you tried downloading the test cases?