BC - A problem of sorting(模拟题)
来源:互联网 发布:monaco 字体 windows 编辑:程序博客网 时间:2024/05/17 22:26
A problem of sorting
Accepts: 445
Submissions: 1706
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
问题描述
给出一张许多人的年龄和生日表。你需要从年轻到年老输出人们的名字。(没有人年龄相同)
输入描述
第一行包含一个正整数T(T≤5),表示数据组数。对于每组数据,第一行包含一个正整数n(1≤n≤100),表示人数,接下来n行,每行包含一个姓名和生日年份(1900-2015),用一个空格隔开。姓名长度大于0且不大于100。注意姓名中只包含字母,数字和空格。
输出描述
对于每组数据,输出n行姓名。
输入样例
21FancyCoder 19962FancyCoder 1996xyz111 1997
输出样例
FancyCoderxyz111FancyCoder
#include <map>#include <set>#include <cstdio>#include <cmath>#include <cstring>#include <vector>#include <queue>#include <iostream>#include <string>#include <sstream>#include <cstdlib>#include <ctime>#include <cctype>#include <algorithm>using namespace std;#define pb push_back#define mp make_pair#define fillchar(a, x) memset(a, x, sizeof(a))#define copy(a, b) memcpy(a, b, sizeof(a))#define S_queue<P> priority_queue<P, vector<P>,greater<P> >typedef long long LL;typedef pair<int, string > PII;typedef unsigned long long uLL;template<typename T>void print(T* p, T* q, string Gap = " ") { int d = p < q ? 1 : -1; while(p != q) { cout << *p; p += d; if(p != q) cout << Gap; } cout << endl;}template<typename T>void print(const T &a, string bes = "") { int len = bes.length(); if(len >= 2)cout << bes[0] << a << bes[1] << endl; else cout << a << endl;}void read(char * str, int &age){ char st[100 + 5]; gets(st); int len = strlen(st); age = atoi(st + len - 4); for(int i = 0;i < len - 4 - 1;i ++){ str[i] = st[i]; } str[len - 4 - 1] = '\0';}const int INF = 0x3f3f3f3f;const int MAXM = 1e5;const int MAXN = 3e5 +5;priority_queue<PII> que;int T, n, age;char str[100 + 5];int main(){ // freopen("D://imput.txt", "r", stdin); cin >> T; while(T --){ while(!que.empty()) que.pop(); cin >> n; getchar(); for(int i = 0;i < n;i ++){ read(str, age); que.push(PII(age, str)); } while(!que.empty()){ print(que.top().second); que.pop(); } } return 0;}
0 0
- BC - A problem of sorting(模拟题)
- HDU 5431/BC 54A A problem of sorting
- A problem of sorting
- HDU5429----A problem of sorting
- HDU5427 - A problem of sorting (简单题)
- BestCoder Round #54 (div.2) HDOJ 5427 A problem of sorting(模拟)
- hdu 5427 A problem of sorting
- hdu 5427 A problem of sorting 排序
- HDU 5427 A problem of sorting 水题
- Bestcoder#54 A problem of sorting
- hdu 5427 A problem of sorting
- hdu 5427 A problem of sorting
- HDU 5427 A problem of sorting
- HDU 5427 A problem of sorting
- hdu 5427 A problem of sorting 排序
- hdu 5427 A problem of sorting(水)
- HDOJ 5427 A problem of sorting
- hdu5427A problem of sorting
- 整数中1出现的次数(从1到n整数中1出现的次数)
- USACO:2.2.3 Runaround Numbers 循环数
- 旋转数组
- 高效运维最佳实践(03):Redis集群技术及Codis实践
- IOS开发UI进阶之UITableView二
- BC - A problem of sorting(模拟题)
- 关于项目中出现一些非代码造成的错误
- 查找第 k 大的元素
- JS+jQuery+Easyui实现动态添加控件及赋值
- Visual Studio Attach Progress Debug
- expect的命令行参数
- Objective-C 面向对象
- HDU 5427 A problem of sorting(字符串处理+排序)——BestCoder Round #54(div.2)
- POJ 3252 Round Numbers (数位dp)