/**
[统计] poj 2761 Feed the dogs
题意: n个数,m个查询,每次查询[l,r]区间里第k小的数。(需要离散化)
题目保证了区间不会相互包含,可以按L排个序。
然后对于每个区间加入新节点,删去旧结点,就成了裸的查第k小。
这里用 树状数组+二分 实现,O(NlogNlogN)
*/
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define N 100001
#define lowbit(i) (i&-i)
struct lisan
{
int val,id;
lisan(int a = 0,int c = 0)
{
val = a;
id = c;
}
}lisa[N];
struct node
{
int x[2],k,id;
void input(int i)
{
id = i;
scanf("%d%d%d",x,x+1,&k);
}
}qua[N];
int val[N],cnt[N];
int n,m;
int ans[N];
bool cmp(node a,node b)
{
return a.x[0] < b.x[0];
}
bool cmp2(lisan a,lisan b)
{
return a.val < b.val;
}
[统计] poj 2761 Feed the dogs
最新推荐文章于 2019-10-17 17:44:37 发布
这是一个关于编程竞赛的博客,介绍了如何利用树状数组和二分查找算法来解决POJ 2761问题,即在给定区间内找到第k小的数。博主提供了C语言实现的代码,并通过离散化处理数据,实现了O(NlogNlogN)的时间复杂度解法。
摘要由CSDN通过智能技术生成