随笔分类 - 数据结构
摘要:题意: 公主被关在 a位置 她的朋友在r位置 路上x位置有恶魔 遇上恶魔花费2 时间 否在时间花费 1 时间 问 最短多少时间 找到公主思路: bfs+ 优先队列(时间短的先出列)#include#include#include#include#include#includeusi...
阅读全文
摘要:实在太困 题都看错先贴王大神的代码有空再做遍#include #include #include #include #include #include #include using namespace std;typedef __int64 LL;LL h,n;LL now1,now2;LL ans...
阅读全文
摘要:StripiesTime Limit:1000MSMemory Limit:30000KTotal Submissions:12528Accepted:5932DescriptionOur chemical biologists have invented a new very useful for...
阅读全文
摘要:题意:直角坐标系上有n个点 每个点的值为它左下的点的数量 求0。。。n-1每个数值出现的次数思路:题目中已经给出y递增 x在y相同时递增 从而可以一边输入一边利用树状数组将结果求出 每次输入时 先计算出 sum(x+1) (由于树状数组下标从1 开始 ,所以每个值都加1,否则会超时) 再 add(x...
阅读全文
摘要:今天终于看懂树状函数了 看懂之后果然感觉比线段树简单便捷地多就拿这题简单的单点更新来练手了#include#include#include#includeusing namespace std;int n;int a[50000+10];int c[50000+10];int lowbit(int ...
阅读全文
摘要:题意:有一块h*w 的广告牌用来贴广告 每个广告 1*w 并且优先贴于左上方 现在给出n个广告的n 问分别贴于第几行 贴不了输出 -1思路:把1-h 作为 l-r 值 套用线段树模版#include#include#include#include#include#include#i...
阅读全文
摘要:题意:有一个序列 要组成多个子序列 每个子序列必须单调递增 问最少组成多少个子序列思路1: 因为严格递增 所以每个数只能在一个子序列中出现一次 出现次数最多的数的次数就是答案 运用 upper_bound(a,a+n,a[i])-lower_bound(a,a+n,a[i]) 求出 (由于数据较水 ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1856题意:有n 对小朋友 两两彼此认识 如果间接认识也可认为认识 问最多能有多人人认识 (注意:在n==0时 ans=1)思路: 通过并查集合并 并在父节点记录朋友个数 #includ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1394DescriptionThe inversion number of a given number sequencea1, a2, ..., an is the number of pairs (ai, aj...
阅读全文

浙公网安备 33010602011771号