第十一届蓝桥杯国赛C\C++A组 奇偶覆盖(扫描线模板)

该博客详细介绍了第十一届蓝桥杯国赛C/C++A组的一道题目,这是一道涉及扫描线模板的算法问题。文章指出,题目的关键在于修改线段树的存储信息,每个节点需记录其覆盖区域内奇数或偶数矩形的长度。考虑到坐标范围大而矩形个数少的特点,博主建议进行离散化处理。提供的代码据称已无误,博主欢迎读者发现问题后私信指正。
摘要由CSDN通过智能技术生成

在这里插入图片描述
本题就是一个扫描线的模板题,但是需要改一下线段树的中存储的信息,每个结点需要存储一下当前结点下多少长度是被奇(或偶数)个矩形覆盖的即可。
并且本题的坐标范围很大,但是个数很少,所以可以离散化一下再做。
本代码应该无任何问题了,如果有佬发现有问题请及时私聊我更改哦~

#include <bits/stdc++.h>
#define IO (ios::sync_with_stdio(false), cin.tie(0), cout.tie(0))
#define INF 0x3f3f3f3f
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vs vector<int>
#define pk push_back
#define vss vector<vector<int> >
#define sz(x) (int)(x).size()
#define mk(a, b) make_pair(a, b)
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define Swap(a, b) (a ^= b, b ^= a, a ^= b)
#define rep(a, b, c) for(register int a = b; a <= c; ++ a)
#define per(a, b, c) for(register int a = b; a >= c; -- a)
using namespace std;

const int N = 1e5 + 5;

int n, m, T;
int alls[N << 1];

struct Segment
{
   
	int x, y1, y2;
	int k;
	bool operator< (const Segment &q) const {
   
		return x < q.x;
	}
} seg[N << 1];

struct Node 
{
   
	int l, r;
	int cnt;
	int len1, len2;
}tr[N << 4];

template<class T>
inline void read(T &x)
{
   
	x = 0; T f = 1; char c = getchar();
	while(c < '0' || c > '9') {
    if(c == '-'
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值