Sign Deliveries

As a big fan of T-mall and TaoBao, shopping on 11.11 is of great importance for HoneyCat. Because she bought too many objects, how to sign deliveries was such big problem. She had  the shipped date of every object(every thing would be shipped in a month), the name of the express company and the number of days it would spend on the way. Can you tell her when and where to sign those deliveries? Your answer should be sorted by the time that the delivery reaches Harbin in ascending order. If several deliveries arrived on the same day, sorted by their express companies’ name in ascending lexicographical order. If they are still same, you should sort the objects’ name in the same way.

输入:

    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;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值