/*
pos[2] = 0 pos[0] = 1 pos[1] = 2
arr[0] = 32.0 arr[1] = 54.7 arr[2] = -2
先印 1 所對到的 再印2 再印3
=> arr[pos[0]] -> arr[pos[1]] -> arr[pos[2]]
Run time: 0.000
*/
#include <stdio.h>
#include <string.h>
#define N 1000
int pos[N];
char arr[N][N];
int main()
{
int n;
int i;
int tmp;
int cnt;
bool state = true;
scanf("%d\n", &n);
while (n--)
{
if (!state) printf("\n");
state = false;
cnt = 0;
while (true)
{
scanf("%d", &tmp);
pos[tmp-1] = cnt++;
if (getchar() == '\n') // 當讀到尾巴
break;
}
for ( i = 0; i < cnt; i++)
scanf("%s", arr[i]);
for ( i = 0; i < cnt; i++)
printf("%s\n", arr[pos[i]]);
}
}
沒有留言:
張貼留言