南邮 OJ 1387 Pythons
来源:互联网 发布:简述网络贷款的危害 编辑:程序博客网 时间:2024/06/03 14:31
Pythons
总提交 : 100 测试通过 : 34
比赛描述
The fish and game commission in South Florida has been catching and measuring
Burmese Pythons in the Everglades. Needless to say, this is a little scary, since these
critters have been rumored to swallow alligators and young computer programmers. The
game officers have been collecting information about their catches, listing the weight in
pounds, along with the date when the snake was caught. Your job is to produce a list of
snakes in ascending order by weight. For any snakes that have the same weight, they
must be listed in ascending order by date.
输入
The first line contains N, indicating the number of data sets that will follow. For each
dataset, the next line contains S, which indicates the number of snake samples in the
current data set. Then, for each value of S, each of the following lines contain two values:
each Python's weight, followed by the date when the python was caught (in mm/dd/yyyy
order), separated by one space. The dates within each data set are guaranteed to be in
ascending order. Here is a sample dataset:
输出
For each dataset, display the snake's weight, followed by a single space, followed by the
date when the snake was caught. Display the values in order by weight from lowest to
highest. This is called the primary sort. But for any duplicate weight values, the dates
should be in increasing order. For example, in the following sample output, notice the
specific ordering of the dates for the three snakes weighing 120 pounds. Follow ever data
set with a blank line. Here is a sample that matches the sample input data:
样例输入
2
3
85 10/22/2008
66 3/1/2009
76 5/12/2009
6
120 4/10/2009
120 6/5/2009
30 8/21/2009
85 9/2/2009
62 10/22/2009
120 1/12/2010
样例输出
66 3/1/2009
76 5/12/2009
85 10/22/2008
By Kip Irvine
30 8/21/2009
62 10/22/2009
85 9/2/2009
120 4/10/2009
120 6/5/2009
120 1/12/2010
提示
undefined
题目来源
Internet
#include<iostream>#include<algorithm>struct python{int weight,day,month,year;};bool operator<(const python &p1, const python &p2){if(p1.weight !=p2.weight){return p1.weight < p2.weight;}if(p1.year != p2.year){return p1.year < p2.year;}if(p1.month != p2.month){return p1.month < p2.month;}return p1.day < p2.day;}int main(){int cas,n,i;python *p;scanf("%d",&cas);while(cas--){scanf("%d",&n);p = new python[n];for(i=0;i<n;i++){scanf("%d %d/%d/%d",&p[i].weight,&p[i].month,&p[i].day,&p[i].year);}std::sort(p,p+n);for(i=0;i<n;i++){printf("%d %d/%d/%d\n",p[i].weight,p[i].month,p[i].day,p[i].year);}printf("\n");delete[] p;}}
- 南邮 OJ 1387 Pythons
- pythons字符编码
- pythons实现LRU算法,纯属个人思路,重复造轮子。
- 南邮OJ B题
- 南邮OJ C题
- 南邮OJ D题
- 南邮oj题型
- 南邮 OJ 1002 求最值
- 南邮 OJ 1027 Quicksum
- 南邮 OJ 1053 恶魔城
- 南邮 OJ 1056 地道
- 南邮 OJ 1073 成绩排名
- 南邮 OJ 1098 Rails
- 南邮 OJ 1105 Game
- 南邮 OJ 1124 Hotel
- 南邮 OJ 1125 Substring
- 南邮 OJ 1126 GCD
- 南邮 OJ 1127 Stick
- C#关于静态函数与普通函数之间的调用问题,以及可变参数的使用
- 优先队列题目
- CentOS6.3搭建NTP服务器
- haproxy 配置和参数说明
- 在IFrame中实现文本的自动换行
- 南邮 OJ 1387 Pythons
- Android Accessibility(辅助功能) --实现Android应用自动安装、卸载
- EditPlus连接Linux服务器远程编辑文件
- [转]协程实现的基础
- Android NDK开发(1)----- Java与C互相调用实例详解
- C语言之static作用
- jQuery京东分类导航菜单
- HDOJ 新兵训练问题 (队列)
- HDU 4528 小明系列故事――捉迷藏