#include #include #include unsigned long offices[1679617]; struct stos { unsigned long value; struct stos* before; }; struct stos *stack; void push(unsigned long val) { struct stos *tmp = (struct stos*)malloc(sizeof(struct stos)); tmp->value = val; tmp->before = stack; stack = tmp; } unsigned long pop() { unsigned long t = stack->value; struct stos *tmp = stack->before; free(stack); stack = tmp; return t; } struct recruts { int pesel; int code; }; int compare(const void *a, const void *b) { struct recruts* r1 = (struct recruts*) a; struct recruts* r2 = (struct recruts*) b; if(r1->pesel > r2->pesel) return 1; else if(r1->pesel < r2->pesel) return -1; else return 0; } int main() { int s, p, z, i; char pesel[12]; char mru[5]; char to[5]; unsigned long temp; int office; struct recruts boys[100000]; struct recruts *r; scanf("%d", &s); while(s--) { memset(offices, 0, sizeof(unsigned long) * 1679617); scanf("%d", &p); for(i=0; icode; stack = (struct stos*)malloc(sizeof(struct stos)); stack->before = NULL; stack->value = office; while(offices[office] != 0) { office = offices[office]; push(office); } pop(); int tmp; while(stack!=NULL) { tmp = pop(); offices[tmp] = office; } free(stack); mru[3] = 48 + office % 36; office /= 36; mru[2] = 55 + office % 36; office /= 36; mru[1] = 55 + office % 36; office /= 36; mru[0] = 55 + office % 36; printf("%s %s\n", pesel, mru); } printf("\n"); } return 0; }