输入:
At the first line, there is an integer T (T ≤ 233), indicates the number of test cases.
In each case, the first line is an integer n, the total number of objects (0 < n ≤ 233).
Then in the following n lines, every line contains two integers m, p and two words, s1, s2. m is the date the company shipped the object, p is the number of days it needed to reach Harbin, s1 is the name of the express company, and s2 is the name of the object (0<m, p<31, the length of s1 and s2 are both in [1, 233]).There will only be ’a’-’z’, ’A’-’Z’ in the words, case sensitive.
If the date is smaller than or equal to 11, the object would be shipped in December.
输出:
输出n行,每行包括快递公司名字和快递的名字
Sample
Input | Output |
1 3 15 8 ZhongTong StampaTshirt 20 3 YuanTong IceSwordSkates 1 1 DangDang LittlePrince | YuanTong IceSwordSkates ZhongTong StampaTshirt Dangdang LittlePrince
|
题意,m是发货日期,如果发货日期小于等于11则这个货物就要等到12月m号才能发货,p是需要p天到达哈尔滨,s1是快递公司的名字,s2是所买东西的名字,让你给他们排序,先到达的先输出,如果到达日期相等,则按快递公司的字典序排序,如果还相等,则按买的快递名字排序。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
const int INF = 0x3f3f3f3f;
const int N = 1005;
const int maxs = 1e6+5;
const double eps = 1e-10;
#define left lll
#define right rrr
#define FOR(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
typedef long long LL;
int x[N],y[N],a[N];
int n,m;
struct node
{
int m,p;
int sum;
string s1,s2;
}xx[N];
bool cmp(node a,node b)
{
if(a.sum==b.sum)
{
if(a.s1==b.s1)
return a.s2<b.s2;
return a.s1<b.s1;
}
return a.sum<b.sum;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d%d",&xx[i].m,&xx[i].p);
cin>>xx[i].s1>>xx[i].s2;
if(xx[i].m<=11)
xx[i].sum=xx[i].p+30+xx[i].m;
else
xx[i].sum=xx[i].m+xx[i].p;
}
sort(xx,xx+n,cmp);
for(int i=0;i<n;i++)
{
cout<<xx[i].s1<<" "<<xx[i].s2<<endl;
}
}
return 0;
}