HDU 4585】的更多相关文章

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…
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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4585 题目大意:不停的插入数字,问你跟他相距近的ID号.如果有两个距离相近的话选择小的那个. 用map,先用upper_bound找到大的,然后迭代器减1,就能够找到相近的两个. 然后..用链表不知道为什么有问题.... 而且迭代器it,如果减1的话,不能写 it2 = --it1; 这样会wa 但是..it2 = it1; it2--;这样就AC了,在这里记录一下,今后注意. //#pragma…
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…
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…
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…
题意: 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.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; } };…
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…
题目链接 题意:有n个人想成为少林,但是成为少林必须跟少林的大师大一场,当然要选择战斗力很近的,有两大师战斗力跟那人相近程度一样就选战斗力小的那个,按输入顺序,先输入的人先成为少林大师,后面输入的人,选一个前面输入的人打一场,当然少林已经存在一个超级大师(初始号码为1,不用输入已存在). 思路:我开头用排序搞来搞去都没成,后来看看人题解,瞬间发觉set很好用,像优先队列一样自己会排好序了. 函数lower_bound()在first和last中的前闭后开区间进行二分查找,返回大于或等于val的第…
set是STL中非常方便的工具,可以实现自动去重和排序,可我一直忽视它的重要性,导致吃了好几次亏. 在思考这道题的时候,我一直往二分上靠拢,可是二分需要直接插入排序,直接插入排序覆盖的时候复杂度最大是n,肯定不行,所以又想链表,结果链表又没办法二分,着实让我相当矛盾. 最后才发现自己忘了这么一个现成的好宝贝,set中有一个lower_bound(num)函数,可以返回第一个大于等于num的数,自动排序,自动二分,一切实现自动化--时间跑了700ms,作为stl的东西也不错,网上博主对stl中ma…
点击打开链接 题意:给出n组数,第一个数是id.第二个数是级别.每输入一个.输出这个人和哪个人打架,这个人会找和他级别最相近的人打,假设有两个人级别和他相差的一样多,他就会选择级别比他小的打架. 思路:用treap完毕,能够用STL水过,但要练Treap就写了平衡树的.对于每一个人的等级,我们找到他的等级的排名t.然后找第t-1大的数和第t+1大的数.然后进行比較一下.讨论后输出,PS:没有好得模版,仅仅能在网上学了一个还能够接受的....... #include <stdio.h> #inc…
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<map> #include<iostream> using namespace std; int main() { int n,id,g; map<int,int>::iterator it,p…
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…
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 scripture, but…
Shaolin HDU - 4585       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 s…
Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7194    Accepted Submission(s): 3345 Problem Description 话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了.显然,作为多年拼搏的商人,XHD不会坐以待毙的.  一天,当他正在苦思冥想解困良策的…
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int jc[100003]; int p; int ipow(int x, int b) { ll t = 1, w = x;…
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格线满足两侧分别是海洋和陆地 这道题很神 首先考虑一下,什么情况下能够对答案做出贡献 就是相邻的两块不一样的时候 这样我们可以建立最小割模型,可是都说是最小割了 无法求出最大的不相同的东西 所以我们考虑转化,用总的配对数目 - 最小的相同的对数 至于最小的相同的对数怎么算呢? 我们考虑这样的构造方法:…
Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4569 Description Let f(x) = a nx n +...+ a 1x +a 0, in which a i (0 <= i <= n) are all known integers. We call f(x) 0 (mod…
The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4006 Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a nu…
How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1796 Description   Now you get a number N, and a M-integers set, you should find out how many integers which are sm…
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pid=4418 读了一遍题后大体明白意思,但有些细节不太确定.就是当它处在i点处,它有1~m步可以走,但他走的方向不确定呢.后来想想这个方向是确定的,就是他走到i点的方向,它会继续朝着这个方向走,直到转向回头. 首先要解决的一个问题是处在i点处,它下一步该到哪个点.为了解决方向不确定的问题,将n个点转…
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/article/details/22569639 这个题目本身简单,我的想法也很easy,但是发生在测试上,我把memset的参数搞错了,第三个是sizeof(a), 比如说int a[10],第三个参数应该是sizeof(10),也就是40,而我传的是10,导致后面的测试,都是答案错误,也就是后面的数据,初始…
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R是前n次输入有关URL的个数  R'是后n次已经输入有关URL的个数 b.   另加:输入 istringstream #include<iostream> #include<sstream> //istringstream 必须包含这个头文件 #include<string&g…
http://acm.hdu.edu.cn/showproblem.php?pid=2586 题意:求最近祖先节点的权值和 思路:LCA Tarjan算法 #include <stdio.h> #include <string.h> #define maxn 40005 ],pos,dist[maxn],f[maxn]; bool vis[maxn]; struct Edge{ int to,val,next; }edge[maxn*]; void add(int u,int v,…