void process (trip a[MAXN], int*ac, char s[MAXN], int sc, int*pos){ if (s[*pos ] == '['){ while (s[*pos] != ']'){ (*pos)++; int num = 0; while ((s[*pos] != ',') && (s[*pos] != ']')) { num = num * 10 + (int)(s[*pos] - '0'); (*pos)++; } a[*ac].first = num; a[*ac].second.first = -1; a[*ac].second.second = -1; (*ac)++; } (*pos)++; } else if (s[*pos ] == 'c'){ (*pos) += 7; process(a, ac, s, sc, pos); (*pos)++; process(a, ac, s, sc, pos); (*pos)++; } else if (s[*pos+1] == 'o'){ (*pos) += 7; int cur = *ac; process2(a, ac, s, sc, pos); qsort(a+cur, (*ac)-cur, sizeof(trip), cmpT); (*pos)++; } else { (*pos) += 8; int cur = *ac; process2(a, ac, s, sc, pos); qsort(a+cur, (*ac)-cur, sizeof(trip), cmpT); if(cmpT(&a[cur], &a[*ac-1])!=0){ for (int i = cur; i < *ac; i++) { a[i].second.first = cur; a[i].second.second = *ac; } } (*pos)++; } }
int ncmp(const number * lhs ,const number * rhs){ return cmpT(lhs?lhs->id:0,rhs?rhs->id:0); }