hdu 4585 map **】的更多相关文章

题意: Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of Shaolin evaluates a young man mainly by his talent on understanding the Buddism scripture, but fightin…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4585 题目大意:不停的插入数字,问你跟他相距近的ID号.如果有两个距离相近的话选择小的那个. 用map,先用upper_bound找到大的,然后迭代器减1,就能够找到相近的两个. 然后..用链表不知道为什么有问题.... 而且迭代器it,如果减1的话,不能写 it2 = --it1; 这样会wa 但是..it2 = it1; it2--;这样就AC了,在这里记录一下,今后注意. //#pragma…
题目大意:原题链接 初始少林最开始只有一个老和尚,很多人想进少林,每个人有一个武力值,若某个人想进少林,必须先与比他早进去的并且武力值最接近他的和尚比武, 如果接近程度相同则选择武力值比他小的,按照进入少林的先后顺序,求出每个和尚进去的时候应当和哪个和尚比武. #include<map> #include<iostream> using namespace std; int main() { int n,id,g; map<int,int>::iterator it,p…
Shaolin Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit cid=57992#status//C/0" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="font-family:Verdana,Arial,sans…
1. map::at #include <iostream> #include <string> #include <map> using namespace std; int main(){ map<string, int> mymap = { {}, {}, {}}; mymap.at(; mymap.at(; mymap.at(; for (auto& x:mymap){ cout<<x.first<<": &…
Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 3191    Accepted Submission(s): 1350 Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shao…
Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of Shaolin evaluates a young man mainly by his talent on understanding the Buddism script…
Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 4370    Accepted Submission(s): 1883 Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaol…
http://acm.hdu.edu.cn/showproblem.php?pid=4585 从原来的人中找出战斗数值最接近的,输出他们两人的序号 要在logn的复杂度完成查找,我用的是set,当然用map也可以,两个内部都是红黑树实现 水题一道 #include <iostream> #include <cstdio> #include <set> #include <cmath> using namespace std ; struct node { i…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10830    Accepted Submission(s): 3472 Problem Description In the year 8888, t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1251 map的强大之处,但是运行时间太长. 代码: #include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> #include <iostream> #include <ctype.h> #include <iomanip> #i…
set是STL中非常方便的工具,可以实现自动去重和排序,可我一直忽视它的重要性,导致吃了好几次亏. 在思考这道题的时候,我一直往二分上靠拢,可是二分需要直接插入排序,直接插入排序覆盖的时候复杂度最大是n,肯定不行,所以又想链表,结果链表又没办法二分,着实让我相当矛盾. 最后才发现自己忘了这么一个现成的好宝贝,set中有一个lower_bound(num)函数,可以返回第一个大于等于num的数,自动排序,自动二分,一切实现自动化--时间跑了700ms,作为stl的东西也不错,网上博主对stl中ma…
Description 经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强.这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市�浦镇陶姚村买了个房子,开始安度晚年了. 这样住了一段时间,徐总对当地的交通还是不太了解.有时很郁闷,想去一个地方又不知道应该乘什么公交车,在什么地方转车,在什么地方下车(其实徐总自己有车,却一定要与民同乐,这就是徐总的性格). 徐总经常会问蹩脚的英文问路:“Can you h…
HDU Today 经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强.这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬浦镇陶姚村买了个房子,开始安度晚年了. 这样住了一段时间,徐总对当地的交通还是不太了解.有时很郁闷,想去一个地方又不知道应该乘什么公交车,在什么地方转车,在什么地方下车(其实徐总自己有车,却一定要与民同乐,这就是徐总的性格). 徐总经常会问蹩脚的英文问路:“Can you hel…
Zjnu Stadium 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3047 Problem Description In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of peop…
1.HDU 2087 2.题意:一个主串,一个子串,求子串在主串里出现了几次. 3.总结:看了题解,还是不太懂.. //#include<iostream>#include<cmath>#include<queue>#include<algorithm> //不明白为什么加上这些头文件就Compilation Error #include<cstring> #include<cstdio> using namespace std; #…
1.HDU 2222 2.题意:给出n个单词,一个字串,求有多少个单词在字串里出现了.注意给出的单词可能会重复,重复的不计. 3.总结:入门题.在查询这里还是不太懂. #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define F(i,a,b) for (int i=a;i<b;i++) #define FF(i,a…
Shaolin Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d , %I64u Java class name: Main [Submit] [Status] [Discuss] Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every…
题目链接 题意:有n个人想成为少林,但是成为少林必须跟少林的大师大一场,当然要选择战斗力很近的,有两大师战斗力跟那人相近程度一样就选战斗力小的那个,按输入顺序,先输入的人先成为少林大师,后面输入的人,选一个前面输入的人打一场,当然少林已经存在一个超级大师(初始号码为1,不用输入已存在). 思路:我开头用排序搞来搞去都没成,后来看看人题解,瞬间发觉set很好用,像优先队列一样自己会排好序了. 函数lower_bound()在first和last中的前闭后开区间进行二分查找,返回大于或等于val的第…
Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 315    Accepted Submission(s): 162 Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin…
没想到map还有排序功能,默认按照键值从小到大排序 #include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <map> #include <algorithm> #include <cstdlib> using namespace std; int main() { int n; int id,g; while(s…
Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 64    Accepted Submission(s): 38 Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin t…
#include<stdio.h> #include<string.h>   #include <iostream> #include <algorithm> #include<string>//必须加这个 #include<cstdio> #define N 11000 #define NN 1100 #define inf 999999999 #include<map> #include<queue> us…
Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9701    Accepted Submission(s): 5210 Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Stat…
题目链接 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6282    Accepted Submission(s): 3551 Problem Description Suppose that we have a square city with straight streets. A map of a city i…
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1484    Accepted Submission(s): 798 Problem Description On Octorber 21st, HDU 50-year-celebration, 50-color balloons floating…
/* * 换行好烦人呀! */ #include <iostream> #include <map> #include <string> using namespace std; map<string,map<string,int>> m; int N; int main() { cin >> N; while (N--) { int n; cin>>n; for (int i = ; i < n; ++i) { s…
Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The mast…
原题链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=46093 #include<algorithm> #include<iostream> #include<cstdlib> #include<cstdio> ; struct Node { int v, s; Node *ch[]; inline void set(int _v, int _s , Node *p) { ch[]…
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<set> #define Maxn 100010 using namespace std; struct Monk{ int id,g; int operator <(const Monk &temp) const { return g<temp.g; } };…