1. C, Andreas Kunft

/*
 * ACM Programming Contest
 * Problem: 482 (Permutation Arrays)
 * Status: Accepted
 * Language: ANSI C
 * Runtime: 0.008
 * Date: 2009-06-30 15:22:21
 * Author: Andreas Kunft
 */

#include <stdio.h>
#include <string.h>

#define MAX_VALUES 1000000
#define MAX_CHARS 1000

int order[MAX_VALUES];
char values[MAX_VALUES][MAX_CHARS];
char tmp;
int elements = 0;

int main() {

int cases, i;

scanf("%d", &cases);
while (cases > 0) {

/* read integers as full line */
while (scanf("%d%[ ]", &order[elements++], &tmp) == 2);

/* read numbers as cstring in the order specified by the order array */
for (i = 0; i < elements; i++) {
scanf("%s", &values[order[i] - 1][0]);
}

for (i = 0; i < elements; i++) {
printf("%s\n", &values[i][0]);
}

cases--;
if (cases != 0)
printf("\n");

elements = 0;
}

return 0;
}