Problem 2088 Longest team name
Problem Description
Jack's class decided to enroll in the Fzu School competition. In order to reflect the unity of the class, the monitor decided to use the class owner's name together to form a history of the longest and most prominent team name.
Because I heard that in the same score, the team name Dictionary small will be ranked in front, the monitor also hope that the longest team name in history has the smallest dictionary order.
Input
The first line of the input data contains an integer t, which represents the number of groups of test data. For each set of test data:
The first behavior is an integer n (0<n<=10000) that represents the number of class members.
Next n Behavior class everyone's name. The name is made up of lowercase letters and each person's name is the same length.
Output for each set of test data, outputs a row that represents the longest team name ever connected. Sample Input13jimtomjoe Sample Outputjimjoetom answerstring has defined <, so the sort is also valid for string and does not require a write comparison function. The direct sort will be sorted by dictionary order. Code
#include <iostream>#include<cstdio>#include<string>#include<Set>#include<algorithm>#include<vector>using namespacestd;intMain () {//freopen ("In.txt", "R", stdin); strings; Vector<string>v; intN; CIN>>N; while(n--) {v.clear (); intN; CIN>>N; for(intI=0; i<n;i++) cin>>S,v.push_back (s); Sort (V.begin (), V.end ()); for(intI=0, Vs=v.size (); i<vs;i++) cout<<V[i]; printf ("\ n"); } return 0;
View Code
Fzu 2088 Longest team name