接分了
#include<stdio.h> #define M 200001 #define Q 65535 struct REC { int data; struct REC *next; } listA[M], listB[M]; struct REC *baseA[1<<16], *baseB[1<<16]; int n; int main(void) { int i, t; struct REC *prec, *prect, **pbase; scanf("%d", &n); prec = listA; for(i=0; i<n; i++) { scanf("%d", &t); prec ++; (*prec).data = t; (*prec).next = baseA[t&Q]; baseA[t&Q] = prec; } prec = listB; pbase = &baseA[Q]; for(i=0; i<=Q; i++) { prect = *pbase; while(prect) { t = (*prect).data; prec ++; (*prec).data = t; (*prec).next = baseB[t>>16]; baseB[t>>16] = prec; prect = (*prect).next; } pbase --; } pbase = &baseB[0]; for(i=0; i<=Q; i++) { prect = *pbase; while(prect) { printf("%d ", (*prect).data); prect = (*prect).next; } pbase ++; } printf("\n"); return 0; }