hdu3183 RMQ】的更多相关文章

A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2742    Accepted Submission(s): 1071 Problem Description Kiki likes traveling. One day she finds a magic lamp, unfortunately the gen…
两个月前做的题,以后可以看看,是rmq关于求区间最值的下标 /* hdu3183 终点 给一个整数,可以删除m位,留下的数字形成一个新的整数 rmq 取n-m个数,使形成的数最小 */ #include<iostream> #include<cstring> #include<cmath> #include<cstdio> #define MAXN 1010 using namespace std; ]; int a[MAXN]; void makeRMQ(…
A Magic Lamp Problem Description Kiki likes traveling. One day she finds a magic lamp, unfortunately the genie in the lamp is not so kind. Kiki must answer a question, and then the genie will realize one of her dreams. The question is: give you an in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183 题解: 方法一:贪心. 在草稿纸上试多几次可以知道,删除数字中从左到右最后一位递增(可以等于)的数字,可以得到最小值,在这个基础下,又继续删除最后一位递增的数字,得到的依然是最小值.这就表明当前这步的贪心不仅是当前最优,而且对于下一步贪心来说也是最优的.所以每次删除最后递增项就可以了. 初期代码(每次循环找最后递增项): Accepted 3183 46MS 1408K 1259 B G++…
3489: A simple rmq problem Time Limit: 40 Sec  Memory Limit: 600 MBSubmit: 1594  Solved: 520[Submit][Status][Discuss] Description 因为是OJ上的题,就简单点好了.给出一个长度为n的序列,给出M个询问:在[l,r]之间找到一个在这个区间里只出现过一次的数,并且要求找的这个数尽可能大.如果找不到这样的数,则直接输出0.我会采取一些措施强制在线. Input 第一行为两个整…
训练指南P198 题意:给出一个非降序排列的整数数组a1, a2…… an,你的任务是对于一系列询问(i,j),回答ai, ai+1 ……aj 中出现的次数最多的次数 这题不仅学到了rmq的应用还学到了游程编码 对于一组数 -1, 1, 1, 2, 2, 2, 4就可以编码成(-1, 1), (1, 2), (2, 3), (4, 1),其中(a, b)表示 b 个连续的 a,cnt[i]表示第 i 段中数出现的次数.num[p] 表示p位置的数所在的段的标号, left[p]表示p位置的数所在…
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1174 题意:中文题诶- 思路:RMQ模板题 关于RMQ: http://blog.csdn.net/liang5630/article/details/7917702 代码: #include <bits/stdc++.h> #define MAXN 10010 using namespace std; ], a[MAXN]; //dp[i][j]存储从下…
Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2229    Accepted Submission(s): 252 Problem Description The shorter, the simpler. With this problem, you should be convinced of this truth.    Y…
Problem F: Tanks a Lot Imagine you have a car with a very large gas tank - large enough to hold whatever amount you need. You are traveling on a circular route on which there are a number of gas stations. The total gas in all the stations is exactly…
inline int lca(int x,int y){ if(x>y) swap(x,y); ]][x]]<h[rmq[log[y-x+]][y-near[y-x+]+]])? rmq[log[y-x+]][x]:rmq[log[y-x+]][y-near[y-x+]+];} 查询代码如上 build(,); ;i<=N;i++) rmq[][i]=list[i]; ,j=,k=;i<=N;log[i]=j,near[i]=k,i++) ) j++,k*=; ,k=;k<=…