int main() { int t, i, j, n, sr, steps; Treap[0].l = Treap[0].r = Treap[0].key = 0; scanf("%d", &t); while (t--) { // memset(Treap,0,MAXNODES*sizeof(item)); scanf("%d", &n); buildtree(1, 1, n, 0); i = n; j = 2; steps = 2; a[1] = a[2] = 1; while (i > 1) { //printf("\n\ncall erase with j=%d steps:%d\n",j,steps); erase_key(1, j, steps - 1); // print_tree(1); i--; steps++; j = ((j + steps - 2) % i) + 1; } a[2] = 1; sr = search_key(1); a[Treap[sr].idx] = steps - 1; for (i = 1; i <= n; i++) printf("%d ", a[i]); printf("\n"); //n==2?printf("2\n"):printf("%d\n",Treap[sr].idx); // (Treap[1].l)? printf("%d\n",Treap[1].idx):printf("%d\n",Treap[1].idx); } return 0; }
int main() { operator_test(); insert_and_find_test(); copy_test(); iterator_operator_plus(); iterator_operator_minus(); clear(); erase_iterator(); erase_key(); }