Last active
October 17, 2016 03:23
-
-
Save fatosmorina/7bcc869044912b31b995a93e2831c4ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.lang.Integer.parseInt; | |
import static java.lang.System.exit; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.OutputStreamWriter; | |
import java.io.PrintWriter; | |
import java.util.StringTokenizer; | |
public class PermutationArrays { | |
static void solve() throws Exception { | |
int numberOfTestCases = nextInt(); | |
while (numberOfTestCases != 0) { | |
nextLine(); | |
String[] indexesString = nextLine().split(" "); | |
int[] indexes = new int[indexesString.length]; | |
for (int i = 0; i < indexesString.length; i++) { | |
indexes[i] = Integer.valueOf(indexesString[i]); | |
} | |
String[] numbers = nextLine().split(" "); | |
String[] resultArray = new String[indexesString.length]; | |
for (int i = 0; i < indexesString.length; i++) { | |
resultArray[indexes[i] - 1] = numbers[i]; | |
} | |
printArray(resultArray); | |
if(numberOfTestCases != 1) | |
System.out.println(); | |
numberOfTestCases--; | |
} | |
} | |
private static void printArray(String[] a) { | |
for (int i = 0; i < a.length; i++) { | |
System.out.println(a[i]); | |
} | |
} | |
static int nextInt() throws IOException { | |
return parseInt(next()); | |
} | |
static String next() throws IOException { | |
while (tok == null || !tok.hasMoreTokens()) { | |
tok = new StringTokenizer(in.readLine()); | |
} | |
return tok.nextToken(); | |
} | |
static String nextLine() throws IOException { | |
return in.readLine(); | |
} | |
public static void main(String[] args) { | |
try { | |
in = new BufferedReader(new InputStreamReader(System.in)); | |
out = new PrintWriter(new OutputStreamWriter(System.out)); | |
solve(); | |
in.close(); | |
out.close(); | |
} catch (Throwable e) { | |
e.printStackTrace(); | |
exit(0); | |
} | |
} | |
static BufferedReader in; | |
static PrintWriter out; | |
static StringTokenizer tok; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment