3475. Mysort 2

Easy函数普通指针排序

时间限制:1000 ms

内存限制:256 MiB

题面

/********** Specification of mysort **********/
void mysort(char *v[], int L, int R);
/* PreCondition:
      v points to an array of char*,
      L,R are indexes of the array to be sorted
   PostCondition:
      to sort with descending order of string lengths.
      If two string have same length, sort with ascending order of strings
*/

#define MAXLINES 5000
char *lineptr[MAXLINES];

void readlines(char *lineptr[], int nlines);

void writelines(char *lineptr[], int nlines);

int main() {
    int nlines;
    scanf("%d\n", &nlines);
    readlines(lineptr, nlines);
/********** mysort is called here *************************/
    mysort(lineptr, 0, nlines - 1);
/***********************************************************/
    writelines(lineptr, nlines);
    return 0;
}
Input

输入格式

  • Line 1: nn (1n5 0001 \le n \le 5~000).
  • Line 2~n+1n+1: A non-empty string each line. Sum of lengths of all strings will not exceed 10610^6.

输出格式

Output the sorted strings.

样例

输入

7
a
b
c
d
ef
ee
bb

输出

bb
ee
ef
a
b
c
d