「LibreOJ β Round」ZQC 的手办 (线段树+堆)

博客介绍了在LibreOJ β Round中的一道题目,涉及到线段树和堆的数据结构应用。题目要求对n个数进行m次操作,操作类型包括区间内数值替换和查询特定数量小于k的元素个数。解题策略可能涉及使用线段树维护区间信息,并结合堆来高效解决查询问题。
摘要由CSDN通过智能技术生成

题意:给出n个数,m种操作,1 l r k ,修改[l, r] 区间内,比k小的为k, 2 l r k x,查询[l,r]区间内比k小的最小的x个数,少于k个输出-1.

http://www.lpoj.cn/problemdetail?problemID=5555

#include<bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int n;
int a[maxn];
int m;
int f,aa,b,k,x;
int tree[maxn<<4];
int lazy[maxn<<4];
int pos[maxn<<4];
int ans[maxn];
struct node {
	int l,r;
	pair<int,int> v;
};
bool operator<(node a,node b) {
	return a.v.first>b.v.first;
}
void pushup(int x) {
//	tree[x] = min(tree[x<<1],tree[x<<1|1]);
	if(tree[x<<1]<tree[x<<1|1]) {
		tree[x] = tree[x<<1];
		pos[x]  = pos[x<<1];
	} else {
		tree[x] = tree[x<<1|1];
		pos[x] = pos[x<<1|1];
	}
}
void pushdown(int rt) {
	tree[rt<<1] = max(tree[rt<<1],lazy[rt]);
	tree[rt
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值