best code #54 div 2 A 水
A problem of sorting
There are many people's name and birth in a list.Your task is to print the name from young to old.(There is no pair of two has the same age.)
First line contains a single integer T≤100T \leq 100T≤100 which denotes the number of test cases.
For each test case, there is an positive integer n(1≤n≤100)n (1 \leq n \leq 100)n(1≤n≤100) which denotes the number of people,and next nnn lines,each line has a name and a birth's year(1900-2015) separated by one space.
The length of name is positive and not larger than 100100100.Notice name only contain letter(s),digit(s) and space(s).
For each case, output nnn lines.
2
1
FancyCoder 1996
2
FancyCoder 1996
xyz111 1997
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
struct node
{
char name[105];
int birthday;
friend bool operator <(node a,node b)
{
return a.birthday<b.birthday;
}
};
node q1,q2;
priority_queue<node>q;
int main()
{
int t,n;
while(scanf("%d",&t)!=EOF)
{
for(int i=1; i<=t; i++)
{
scanf("%d",&n);
getchar();
for(int j=1; j<=n; j++)
{
char str[105],strr[105];
int birth;
memset(strr,0,sizeof(strr));
memset(str,0,sizeof(str));
cin.getline(str,105);
int len=strlen(str);
birth=str[len-1]-'0'+(str[len-2]-'0')*10+(str[len-3]-'0')*100+(str[len-4]-'0')*1000;
for(int k=0; k<=len-1-5; k++)
{
strr[k]=str[k]; }
strcpy(q1.name,strr);
q1.birthday=birth;
q.push(q1);
}
while(!q.empty())
{
q2=q.top();
q.pop();
cout<<q2.name<<endl;
}
}
}
return 0;
}
best code #54 div 2 A 水的更多相关文章
- Codeforces Beta Round #54 (Div. 2)
Codeforces Beta Round #54 (Div. 2) http://codeforces.com/contest/58 A 找子序列 #include<bits/stdc++.h ...
- Codeforces Round #365 (Div. 2) A 水
A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #303 (Div. 2) B 水 贪心
B. Equidistant String time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #303 (Div. 2) A 水
A. Toy Cars time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Codeforces Round #394 (Div. 2)A水 B暴力 C暴力 D二分 E dfs
A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #169 (Div. 2) A水 B C区间更新 D 思路
A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #337 (Div. 2) A水
A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #364 (Div. 2) A 水
A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #316 (Div. 2) A 水
A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- spring boot 报错 Error creating bean with name
Application 启动类 要和父目录平级
- leetcode-三数之和(java)
三数之和 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组. 注意:答案中不可 ...
- JAVA基础学习之路(七)对象数组的定义及使用
两种定义方式: 1.动态初始化: 定义并开辟数组:类名称 对象数组名[] = new 类名称[长度] 分布按成:类名称 对象数组名[] = null: 对象数组名 = new 类名称[长度]: 2 ...
- 给eclipse安装color-theme插件
给eclipse安装color-theme插件 2016年03月22日 19:16:01 ming_love 阅读数:5193 标签: Eclipse Color Theme 更多 个人分类: jav ...
- hibernate 异常a different object with the same identifier value was already associated with the session
在使用hibernate的时候发现了一个问题,记录一下解决方案. 前提开启了事务和事务间并无commit,进行两次save,第二次的时候爆出下面的异常a different object with t ...
- 为什么请求时,需要使用URLEncode做encode转码操作(转)
什么要对url进行encode 发现现在几乎所有的网站都对url中的汉字和特殊的字符,进行了urlencode操作,也就是: http://hi.baidu.com/%BE%B2%D0%C4%C0%C ...
- Servlet过滤器介绍之原理分析
zhangjunhd 的BLOG 写留言去学院学习发消息 加友情链接进家园 加好友 博客统计信息 51CTO博客之星 用户名:zhangjunhd 文章数:110 评论数:858 访问量:19 ...
- Java内存管理特点
Java内存管理特点 Java一个最大的优点就是取消了指针,由垃圾收集器来自动管理内存的回收.程序员不需要通过调用函数来释放内存. 1.Java的内存管理就是对象的分配和释放问题. 在 ...
- codeforces 359E Neatness(DFS+构造)
Simon loves neatness. So before he goes to bed, Simon wants to complete all chores in the house. Sim ...
- 关于LNMP常见问题和性能方面的个人理解
简单整理,自己做备忘的,不为其他作任何参考- PHP程序 1.开启慢日志,过滤超时时间为1s的方法,针对性优化,可以通过添加缓存方式解决. 2.过滤access日志,统计哪些请求较多较为频繁,是否合理 ...