HDU 5037 FROG (贪婪)】的更多相关文章

Problem Description Once upon a time, there is a little frog called Matt. One day, he came to a river. The river could be considered as an axis.Matt is standing on the left bank now (at position 0). He wants to cross the river, reach the right bank (…
哎,注意细节啊,,,,,,,思维的严密性..... 11699193 2014-09-22 08:46:42 Accepted 5037 796MS 1864K 2204 B G++ czy Frog Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 454    Accepted Submission(s): 96 Problem…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5037 题解:为了让放的石头有意义肯定是没l+1的距离放2个也就是说假设现在位置为pos那么在pos+1放一个在pos+l+1放一个这样就需要跳两次.于是这题要考虑的就是当前位置和前一个石头放的位置因为如果前一个石头的位置到a[i]的距离小于等于l那么当前位置就不能被走到.所以就拿l+1的距离来贪心. #include <iostream> #include <cstring>…
题意比较难懂,一只青蛙过河,它最多一次跳L米,现在河中有石头,距离不等,上帝可以往里加石头,青蛙非常聪明,它一定会选择跳的次数最少的路径.问怎么添加石头能让青蛙最多的次数.输出青蛙跳的最多的次数. 考虑对于长度L+1,上帝一定会让青蛙跳两次.那么只需要尽可能的构造L+1就行了.那么就需要求多少个L+1就行了.还有就是需要记录上一次跳的距离,如果上一次跳的距离加上这次的距离小于L+1的话,那么上次一定会跳到当前这个点,而不是跳到上次那个点,所以更新一下上次的距离.也就是这两种情况: 1)上一步pr…
开始就觉得有思路,结果越敲越麻烦...  题意很简单,就是说一个青蛙从0点跳到m点,最多可以跳l的长度,原有石头n个(都仅表示一个点).但是可能跳不过去,所以你是上帝,可以随便在哪儿添加石头,你的策略是让青蛙跳过去的次数最多,但是你添加了石头后,青蛙会选择最少的次数跳过去,问青蛙跳的次数最多是多少. 原有石头与现在的距离不大于l,就找最远的那个可以跳的石头跳过去.接下来就是主要解决现在的位置与接下来的一块石头的距离大于l的情况了.模拟:上帝开始放石头,要让青蛙一定是这次跳这块石头(在上次不能跳)…
http://acm.hdu.edu.cn/showproblem.php?pid=5037 有只青蛙踩石子过河,河宽m,有n个石子坐标已知.青蛙每次最多跳L.现在可以在河中再放一些石子,使得青蛙过河跳的次数最多. 青蛙是贪心的,的位置. 使用模拟+周期优化 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #inc…
Frog Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 712    Accepted Submission(s): 338 Problem Description A little frog named Fog is on his way home. The path's length is N (1 <= N <= 100),…
/* 模拟 实例: 33 1 10 5 5 2 10 3 3 6 1 3 2 1 1 4 2 1 1 5 2 1 1 6 2 1 1 7 2 1 5 20 8 1 2 3 4 5 1 20 8 5 0 20 8 2 4 2 3 3 4 5 4 4 5 */ #include<stdio.h> #include<stdlib.h> #define N 2100000 int a[N]; int num; int cmp(const void *a,const void *b) { r…
话说这题读起来真费劲啊,估计很多人做不出来就是因为题读不懂...... 从题目中提取的几点关键点: 题目背景就是银河系(Rho Galaxy)中的星球都是绕着他们的质心(center of mass)转的(妈蛋就是这里啊,质心是个什么鬼...,其实就是所有点的值的算术平均值). 现在你可以从一个银河系中的所有星球中转移其中的k个(具体这个转移的意思你可以理解成把他们移到剩下星球的质心上,这样对剩余的整体不会产生影响,当然这也等价于把这k个星球直接删了),然后使剩下的星球让这个The moment…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4004 The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over…
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5578 Description N frogs from different countries are standing in a line. Each country is represented by a lowercase letter. The distance betwee…
Mr. Frog's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 277    Accepted Submission(s): 192 Problem Description One day, Mr. Frog is playing Link Game (Lian Lian Kan in Chinese).In this g…
Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 312    Accepted Submission(s): 219 Problem Description One day, you, a clever boy, feel bored in your math class, and then fall…
Problem Description N frogs . Two frogs are friends if they come from the same country. The closest friends are a pair of friends with the minimum distance. Help us find that distance. Input First line contains an integer T, which indicates the numbe…
http://acm.hdu.edu.cn/showproblem.php?pid=4550 想了挺久,然后各种分类 最终AC,假设是现场,对自己没信心的话,预计还是要WA,,,,,,然后搜题解,发现人家都觉得是简单题,看来我还是太弱了,牡丹江没有做出来K看来还是自己贪心和思维有问题 d是一个Deque 最朴素的算法是,假设当前的数<=d.front(),那么插入队列的前面,否则插入队列后面,可是有零所以须要单独处理,还是自己多举例找规律 我的策略: 1.记录0的个数zero,最小非零的数的个数…
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=3177 Problem Description Crixalis - Sand King used to be a giant scorpion(蝎子) in the deserts of Kalimdor. Though he's a guardian of Lich King now, he keeps the living habit of a scorpion like living und…
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=4296 Buildings Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1822    Accepted Submission(s): 722 Problem Description Have you ever heard the st…
题目链接:hdu 4912 Paths on the tree 题目大意:给定一棵树,和若干个通道.要求尽量选出多的通道,而且两两通道不想交. 解题思路:用树链剖分求LCA,然后依据通道两端节点的LCA深度排序,从深度最大优先选.推断两个节点均没被标 记即为可选通道. 每次选完通道.将该通道LCA下面点所有标记. #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #includ…
主题链接:pid=4864">http://acm.hdu.edu.cn/showproblem.php?pid=4864 Task Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1346    Accepted Submission(s): 336 Problem Description Today the company h…
Problem Description Jack and Jill play a game called "Leap Frog" in which they alternate turns jumping over each other. Both Jack and Jill can jump a maximum horizontal distance of 10 units in any single jump. You are given a list of valid posit…
The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 10307    Accepted Submission(s): 4686 Problem Description The annual Games in frogs' kingdom started again. The most famous game…
Leap Frog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 676    Accepted Submission(s): 244 Problem Description Jack and Jill play a game called "Leap Frog" in which they alternate turns…
The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 9678    Accepted Submission(s): 4428 The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triat…
题目链接 题意理解的有些问题. #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define LL __int64 LL p[]; int n; int judge(int x,int m) { ,num = ,i; ;i <= n;i ++) { if(p[i] - pre <= x) ; else…
题 题意 求相同字母最近距离 分析 用数组保存各个字母最后出现的位置,维护最小距离. 代码 #include <cstdio> int c[30],n,p,a,minl; char ch; int main(){ scanf("%d ",&n); for(int i=1;i<=n;i++){ for(int j=0;j<27;j++)c[j]=0; p=1;minl=2000; while((ch=getchar())!='\n'){ a=ch-'a';…
职务地址:pid=4864">HDU4864 这题又是一上来觉得是最小费用流,可是边太多.果然,敲完交上去后不断TLE.. 小优化了两次也没过. . . sad.. 后来看了题解才发现是贪心. ..贪心也不好想.大体思路是非常好想的.就是先都按时间从大到小排序,再遍历任务,从机器里找能匹配的.并在能匹配的里边找等级尽量小的与之匹配.对我来说的突破点在于找能匹配的机器时不是每次都要又一次找一遍.而是能够直接利用曾经找到的. 这就避免了n^2的复杂度.这种时间复杂度就仅仅有m*100,明显不会…
其实这个题呢,大白书上面有经典解法  题意是青蛙要跳过长为L的河,河上有n块石头,青蛙最多只能跳m次且只能跳到石头或者对面.问你青蛙可以跳的最远距离的最小值是多大 典型的最大值最小化问题,解法就是贪心二分.其实就是二分答案,再把每次二分出来的答案带入计算是否满足题意,以此来确定这个正确答案在此值的左区间还是右区间.可以这么做的依据是:对于二分出来的值x满足条件的话,则大于x(或者小于x)也满足条件,这样就得到一个单调的规律,满足二分. #include<set> #include<map…
题意:给定一行字符串(都是小写字母),每一个字符都代表一只青蛙以及其国籍,若字符串中出现两个字符相同,则这两个字符所代表的青蛙来自同一国度,可称之为好朋友. 现在需要找到距离最近的好朋友并输出他们的距离. 思路:建立一个map映射表,映射关系为:字符<->字符所在字符串的位置,从字符串头部到尾部依次进行扫描,每扫到一个字符,可以找一找map表中有没有出现该字符,若没出现过则在 表中建立这个字符的关系,若map表中有该字符的记录,那么说明当前字符串代表的青蛙找到了一个朋友,可以计算他与朋友的距离…
Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 556    Accepted Submission(s): 127 Special Judge Problem Description Good news for us: to release the financial pressure, the government…
http://acm.hdu.edu.cn/showproblem.php?pid=5037 网络赛 北京 比较难的题 Frog Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 99    Accepted Submission(s): 11 Problem Description Once upon a time, there is…