HDU 1896 Stones(优先队列)】的更多相关文章

Problem Description Because of the wrong status of the bicycle, Sempr begin to walk east to west every morning and walk back every evening. Walking may cause a little tired, so Sempr always play some games this time. There are many stones on the road…
一直向前搜..做法有点像模拟.但是要用到出队入队,有点像搜索. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <queue> using namespace std; #define N 100003 struct node { int p,d; bool opera…
Stones Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 662    Accepted Submission(s): 391 Problem Description Because of the wrong status of the bicycle, Sempr begin to walk east to west every m…
还是优先队列 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; #define maxn 100010 struct Node { int x,y,id; friend bool operator < (Node a,Node b) { if(a.x != b.x) return a.x > b.x; else if…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1896 题目意思:给出 n 块石头的初始位置和能到达的距离.对于第奇数次遇到的石头才抛掷,偶数次的就忽略.问最多能扔到多远.如果有多颗石头在一个位置,距离小的那个标记为先遇到的. 所以先解说一下第二个测试案例: 2 1  5 6  6 在6这个位置的时候,由于5比6小,所以规定1(5)这个点是先遇上的,是偶数次遇到,所以忽略. 用优先队列做,位置近的优先级越高,如果位置相同,距离短的优先级越高. #i…
http://acm.hdu.edu.cn/showproblem.php?pid=1509 裸的优先队列的应用,输入PUT的时候输入名字,值和优先值进队列,输入GRT的时候输出优先值小的名字和对应的值 注意的是优先级一样的时候输出顺序在前的 #include<cstdio> #include<cstring> #include<queue> using namespace std; struct point { int val,odr,num; ]; bool ope…
Stones Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 4165    Accepted Submission(s): 2699 Problem Description Because of the wrong status of the bicycle, Sempr begin to walk east to west ever…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1896 题目大意: 有n个石头,每个石头有:p  它所在的位置 ,d  它能扔多远 从0 开始,遇到第奇数个石头就扔出去,否则则无视,如果同一位置多个石头,则先遇到扔得近的,问最远的石头在什么位置. 采用优先队列. 奇数则p=p+d,弹出,再重新放入,偶数则直接弹出,输出最后一个石头所在的位置. 优先队列: empty() 如果队列为空返回真 pop() 删除对顶元素 push() 加入一个元素 si…
Stones Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1363    Accepted Submission(s): 850 Problem Description Because of the wrong status of the bicycle, Sempr begin to walk east to west every…
来源1896 Because of the wrong status of the bicycle, Sempr begin to walk east to west every morning and walk back every evening. Walking may cause a little tired, so Sempr always play some games this time. There are many stones on the road, when he mee…