STL的使用。

 /* 5131 */
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std; #define MAXN 205 typedef struct {
string s;
int i, n;
} hero_t; typedef struct node_t {
int mmin, mmax;
node_t() {}
node_t(int a, int b) {
mmin = a; mmax = b;
}
} node_t; hero_t heros[MAXN]; bool comp(hero_t a, hero_t b) {
if (a.n == b.n)
return a.s < b.s;
else
return a.n > b.n;
} int main() {
int n, m;
int i, j, k, id = ;
string s;
node_t nd; ios::sync_with_stdio(false); #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif while (cin>>n && n) {
for (i=; i<n; ++i) {
heros[i].i = i;
cin >>heros[i].s>>heros[i].n;
} sort(heros, heros+n, comp);
for (i=; i<n; ++i)
cout <<heros[i].s<<' '<<heros[i].n<<endl; map<string, node_t> tb;
i = ;
while (i < n) {
j = ;
while ((i+j)<n && heros[i+j].n == heros[i].n)
++j;
if (j > ) {
for (k=; k<j; ++k) {
tb[heros[i+k].s] = node_t(k+, i+);
}
i += j;
} else {
tb[heros[i].s] = node_t(, i+);
++i;
}
}
cin >>m;
while (m--) {
cin >>s;
nd = tb[s];
if (nd.mmin == )
cout <<nd.mmax<<endl;
else
cout <<nd.mmax<<' '<<nd.mmin<<endl;
}
id = ;
} return ;
}

【HDOJ】5131 Song Jiang's rank list的更多相关文章

  1. hdu 5131 Song Jiang's rank list

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5131 Song Jiang's rank list Description <Shui Hu Z ...

  2. HDU 5131.Song Jiang's rank list (2014ACM/ICPC亚洲区广州站-重现赛)

    Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java ...

  3. 【HDOJ】5096 ACM Rank

    Treap+set仿函数重定义.每当ac一道题目时,相当于对总时间减去一个大数. /* 5096 */ #include <iostream> #include <string> ...

  4. 【HDOJ】1811 Rank of Tetris

    并查集+拓扑排序.使用并查集解决a = b的情况. #include <iostream> #include <cstdio> #include <cstring> ...

  5. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  6. 【HDOJ】4601 Letter Tree

    挺有意思的一道题,思路肯定是将图转化为Trie树,这样可以求得字典序.然后,按照trie的层次求解.一直wa的原因在于将树转化为线性数据结构时要从原树遍历,从trie遍历就会wa.不同结点可能映射为t ...

  7. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

  8. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  9. 【HDOJ】【3480】Division

    DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...

随机推荐

  1. UIScreen UIWindow UIView

    UIScreen(屏幕),UIWindow(窗口),UIView(视图)是IOS的几个基本界面元素.其中UIWindow(窗口)和UIView(视图)是为iPhone应用程序构造用户界面的可视组件.U ...

  2. XML转义特殊字符

    正常来说,只有"<" 字符和"&"字符对于XML来说是严格禁止使用的. 需要注意的是: a. 转义序列各字符间不能有空格: b. 转义序列必须以& ...

  3. [Angular 2] Inject Service

    TypeScript is used heavily as we build up our application, but TypeScript isn’t required. If you wan ...

  4. hdu 1882 Strange Billboard(位运算+枚举)

    http://acm.hdu.edu.cn/showproblem.php?pid=1882 感觉非常不错的一道题. 给一个n*m(1<=n,m<=16)的矩阵,每一个格子都有黑白两面,当 ...

  5. String.Split()函数

    我们在上次学习到了 String.Join函数(http://blog.csdn.net/zhvsby/archive/2008/11/28/3404704.aspx),当中用到了String.SPl ...

  6. pythonQQ邮件

    http://www.cnblogs.com/lonelycatcher/archive/2012/02/09/2343463.html http://blog.csdn.net/imzoer/art ...

  7. post 封装Map 发送请求

    package com.j1.weixin.util; import java.io.IOException; import java.util.Map; import java.util.Set; ...

  8. HDU5327

    #include <iostream> #include <stdio.h> #include <cstring> using namespace std; int ...

  9. 基于Bootstrap实现下图所示效果的页面,一个白底的带有两个菜单项、一个下拉菜单和一个登录表单的基本导航条

    <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8& ...

  10. HTML 详细介绍

    什么是 HTML? HTML 是用来描述网页的一种语言. HTML 指的是超文本标记语言 (Hyper Text Markup Language) HTML 不是一种编程语言,而是一种标记语言 (ma ...