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
    评论
SQLAlchemy 是一个 SQL 工具包和对象关系映射(ORM)库,用于 Python 编程语言。它提供了一个高级的 SQL 工具和对象关系映射工具,允许开发者以 Python 类和对象的形式操作数据库,而无需编写大量的 SQL 语句。SQLAlchemy 建立在 DBAPI 之上,支持多种数据库后端,如 SQLite, MySQL, PostgreSQL 等。 SQLAlchemy 的核心功能: 对象关系映射(ORM): SQLAlchemy 允许开发者使用 Python 类来示数据库,使用类的实例中的行。 开发者可以定义类之间的关系(如一对多、多对多),SQLAlchemy 会自动处理这些关系在数据库中的映射。 通过 ORM,开发者可以像操作 Python 对象一样操作数据库,这大大简化了数据库操作的复杂性。 达式语言: SQLAlchemy 提供了一个丰富的 SQL 达式语言,允许开发者以 Python 达式的方式编写复杂的 SQL 查询。 达式语言提供了对 SQL 语句的灵活控制,同时保持了代码的可读性和可维护性。 数据库引擎和连接池: SQLAlchemy 支持多种数据库后端,并且为每种后端提供了对应的数据库引擎。 它还提供了连接池管理功能,以优化数据库连接的创建、使用和释放。 会话管理: SQLAlchemy 使用会话(Session)来管理对象的持久化状态。 会话提供了一个工作单元(unit of work)和身份映射(identity map)的概念,使得对象的状态管理和查询更加高效。 事件系统: SQLAlchemy 提供了一个事件系统,允许开发者在 ORM 的各个生命周期阶段插入自定义的钩子函数。 这使得开发者可以在对象加载、修改、删除等操作时执行额外的逻辑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值