上一页 1 2 3 4 5 6 7 ··· 48 下一页
  2013年9月19日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4747设我们输入的数组为 a[],我们需要从 1 到 n 遍历, 假设遍历到 i 时,遍历的过程中用b[j]表示从 i 到 j 没出现的最小自然数先从 n 到 1 扫一遍求出从 1 到各个点的b[j]值然后遍历a[] 实际上就是不断的把当前a[i] 去掉,比如说去掉a[3]时,剩下的b[4]---b[n] 就表示从4到其他后续点形成的区间中没出现的最小自然数要知道从 i 到 n ,b[]的值始终是单调递增的我们每去掉当前a[i]会对b[]数组产生影响,设下一个和a[i]相等的数出现的位置是 r 那么去掉a[i 阅读全文
posted @ 2013-09-19 21:51 夜-> 阅读(232) 评论(0) 推荐(0) 编辑
  2013年8月2日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1427没想到这道题错了N遍 细节很重要呀代码:#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef pair pp;typedef long long ll;const int N=100005;char s[N];int main(){ //freopen("data.in","r&quo 阅读全文
posted @ 2013-08-02 20:19 夜-> 阅读(225) 评论(0) 推荐(0) 编辑
  2013年8月1日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4635我们把缩点后的新图(实际编码中可以不建新图 只是为了概念上好理解)中的每一个点都赋一个值表示是由多少个点缩成的 我们需要找所有端点 也可能出发点(只有出度) 也可能是结束点 (只有入度)这个端点和外界(其它所有点)的联通性是单向的(只入或只出) 也可能没有联通在保持这个端点与外界的单向联通性的情况下 任意加边所以当端点的值越小(包含点越少) 结果越优代码:#include#include#include#include#include#include#include#include#include#in 阅读全文
posted @ 2013-08-01 19:29 夜-> 阅读(196) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4642对于给定的矩阵 操作步数的奇偶性是确定的奇数步Alice赢 否则Bob赢从左上角向右下角遍历遇到1就进行一次处理 遍历到 (x,y) 的时候必须保证 所有(x,y)左上方的点都处理完了可以根据左上方处理时对(x,y)产生的影响 判断(x,y)的状态代码:#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pairpp 阅读全文
posted @ 2013-08-01 19:09 夜-> 阅读(211) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4639每一段 "hehe..... " 相互独立 将每一段 "hehe..... "可以形成的种类 相乘代码:#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pairppd;const double PI = acos(-1.);const double eps = (1e-9) 阅读全文
posted @ 2013-08-01 18:58 夜-> 阅读(195) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4632简单DP代码:#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pairppd;const double PI = acos(-1.);const double eps = (1e-9);const int MOD=10007;const int N=1005;char s[N];int ans[N][N];int 阅读全文
posted @ 2013-08-01 18:53 夜-> 阅读(158) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4638问题其实就是求[L,R]中有多少个连续的段若每一个人都是一个段 那么[L,R]中每一个朋友关系就会减少一个段(因为它将两个段合并了)我们把每个朋友关系变成一个边 要求[L,R]有多少个边 可以用到 离散化+树状数组把每个朋友关系形成的边以左端点为key从大到小排序 遍历时将右端点不断的插入当左端点为key的边全部插入的时候 那么所有[L,R]中L等于key的询问都可求了代码:#include#include#include#include#include#include#include#include# 阅读全文
posted @ 2013-08-01 18:45 夜-> 阅读(235) 评论(0) 推荐(0) 编辑
  2013年7月31日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4630离散化+树状数组将数组 *a 从后向前遍历 遍历到 a[x] 的时候 再枚举a[x]的约数 假如 约数 klast[k] 对应到 上一个k出现的位置 那么可被公约数 k 更新的区间是 last[k] --- 最后把所有a[x]的约数都处理完之后 从 x 到任意 y(y>=x)形成的段的 最优解都可求代码:#include#include#include#include#include#include#include#include#includeusing namespace std;typede 阅读全文
posted @ 2013-07-31 20:32 夜-> 阅读(220) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4631没想到这道题需要用“平均时间复杂度” 计算 一直没有想到解法 因为不符考虑了最坏情况的理念方法一:每加一个点 就找x值和它接近的 有可能更新最小距离的点进行判断更新 运行的相当的快 无语方法二:每求出所有点的最近点对 假如说是p[i],p[j](i#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pairppd;const double PI = 阅读全文
posted @ 2013-07-31 16:02 夜-> 阅读(190) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4628状态压缩DP 时间复杂度应该是 16*(2^32)但是运行时要远小于这个数 所以加一定剪枝就可以过代码:#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef pairppd;const double PI = acos(-1.);const double eps = (1e-9);const int N=20;const int M=(1>s; 阅读全文
posted @ 2013-07-31 15:49 夜-> 阅读(189) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 48 下一页