#include const int maxn = 50000; char charseq[21 * maxn]; bool smaller(int i, int j){ //check whether // the string starting at the i-th position is smaller than the string starting at the j-th position while (charseq[i]!='\0'&&charseq[j]!='\0'){ if (charseq[i]==charseq[j]){ i++; j++; }else return (charseq[i]= r) return; int key = s[p[r]]; int i = l; for (int j = l; j < r; j++) if ( smaller(s[p[j]], key)){ swap(p[i], p[j]); i++; } swap(p[i], p[r]); sort(l, i-1); sort(i+1, r); } int main(){ scanf("%d", &n); getchar(); int x = 0; for(int i=0;i