/**
* @author Divyanshu
* @mail divyanshu17x@gmail.com
* @veredict Accepted
* @problemId 482
* @problemName Permutation Arrays
* @judge http://uva.onlinejudge.org/
* @category Simulation
* @level easy
* @date 24/07/2014
**/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class UVa482 {
public static void main (String args[]) throws Throwable{
BufferedReader in = new BufferedReader( new InputStreamReader(System.in));
for(int i = 0 , C = Integer.parseInt(in.readLine().trim()); i < C ; ++i)
{
//read an empty line
in.readLine();
//read the two strings
String permutedArray[] = in.readLine().trim().split(" ") ,
toPermute[] = in.readLine().trim().split(" "),
sol [] = new String[toPermute.length];
int length = toPermute.length ;
//fill the solution as per xpi = xi
for(int k = 0 ; k < length ; ++k)
sol[Integer.parseInt(permutedArray[k]) - 1] = toPermute[k];
//display the solution
for(int k = 0 ; k < length ; ++k) System.out.println(sol[k]);
if(i<C-1)System.out.println();
}
}
}
No comments:
Post a Comment