1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| #include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct qd {
char s[20];
char kai[10];
char guan[10];
};
bool vsk(qd A,qd B) {
return strcmp(A.kai,B.kai)<0;
}
bool vsg(qd A,qd B) {
return strcmp(A.guan,B.guan)>0;
}
int main() {
int N,M;
scanf("%d",&N);
while(N--) {
scanf("%d",&M);
int i;
struct qd a[M];
for(i=0; i<M; i++)
scanf("%s %s %s",&a[i].s,&a[i].kai,&a[i].guan);
sort(a,a+M,vsk);
printf("%s ",a[0].s);
sort(a,a+M,vsg);
printf("%s\n",a[0].s);
}
return 0;
}
|