很早以前就已经做过这道题,不过这次做AC steps又做了一遍,用了stl。挺爽的。直接上代码,没什么好说的。
/*
ID:狂人
num:09073355
E-mail:wenboguo@live.com
*/
#include <vector>
#include <list>
#include <assert.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <fstream>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a) (int(a.size()))
#define mp make_pair
#define pb push_back
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> ii;
typedef pair<string, string>ss;
typedef long double ld;
const int INF = 0x7ffffff;
struct Node{
string str1;
string str2;
Node(string st1, string st2):str1(st1),str2(st2){}
bool operator < (const Node &a) const
{
return a.str1 < str1;
}
};
struct Node1{
string str1;
string str2;
Node1(string st1, string st2):str1(st1),str2(st2){}
bool operator < (const Node1 &a) const
{
return a.str1 > str1;
}
};
int main()
{
//ifstream cin ("aaa.txt");
int n;
cin >> n;
while (n--)
{
int m;
priority_queue <Node>my_que;
priority_queue <Node1>my_que1;
string str1, str2, myname;
cin >> m;
while (m--)
{
cin >> myname;
cin >> str1;
cin >> str2;
my_que.push(Node(str1, myname));
my_que1.push(Node1(str2, myname));
}
cout << my_que.top().str2 << " ";
cout << my_que1.top().str2 << endl;
}
// system("pause");
return 0;
}