POJ 2528 Mayor's posters

信号检测算法的MATLAB仿真:能量检测、循环平稳检测和匹配滤波检测 根据具体的应用场景和要求,选择合适的信号检测算法可以提高系统的性能和可靠性。在无线电通信中,信号检测是一项重要的任务,它用于检测和识别接收到的信号。在本文中,我们将介绍三种常用的信号检测算法:能量检测、循环平稳检测和匹配滤波检测,并提供相应的MATLAB源代码进行仿真实现。在上述代码中,我们首先设置了能量检测的阈值,然后生成了一个包含1000个服从正态分布的随机信号样本的信号。在上述代码中,我们首先设置了信号模板,然后生成了一个包含信号模板的信号样本。最后,通过比较相关性的最大值与阈值来判断信号是否存在。 阅读详情

Mayor’s posters

https://vjudge.net/problem/POJ-2528
The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the posters and introduce the following rules:
Every candidate can place exactly one poster on the wall.
All posters are of the same height equal to the height of the wall; the width of a poster can be any integer number of bytes (byte is the unit of length in Bytetown).
The wall is divided into segments and the width of each segment is one byte.
Each poster must completely cover a contiguous number of wall segments.

They have built a wall 10000000 bytes long (such that there is enough place for all candidates). When the electoral campaign was restarted, the candidates were placing their posters on the wall and their posters differed widely in width. Moreover, the candidates started placing their posters on wall segments already occupied by other posters. Everyone in Bytetown was curious whose posters will be visible (entirely or in part) on the last day before elections.
Your task is to find the number of visible posters when all the posters are placed given the information about posters’ size, their place and order of placement on the electoral wall.
Input
The first line of input contains a number c giving the number of cases that follow. The first line of data for a single case contains number 1 <= n <= 10000. The subsequent n lines describe the posters in the order in which they were placed. The i-th line among the n lines contains two integer numbers l i and ri which are the number of the wall segment occupied by the left end and the right end of the i-th poster, respectively. We know that for each 1 <= i <= n, 1 <= l i <= ri <= 10000000. After the i-th poster is placed, it entirely covers all wall segments numbered l i, l i+1 ,… , ri.
Output
For each input data set print the number of visible posters after all the posters are placed.

The picture below illustrates the case of the sample input.
在这里插入图片描述
Sample Input
1
5
1 4
2 6
8 10
3 4
7 10
Sample Output
4
C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

const int MAXN = 10000 + 10;

struct node{
	int l, r, lazy;
}segTree[MAXN << 2];

int cnt, vis[MAXN], L[MAXN], R[MAXN], H[MAXN << 1];

void pushdown(int x)
{
	if(segTree[x].lazy != -1)
	{
		segTree[x << 1].lazy = segTree[x << 1 | 1].lazy = segTree[x].lazy;
		segTree[x].lazy = -1;
	}
}

void build(int x, int l, int r)
{
	segTree[x].l = l;
	segTree[x].r = r;
	if(l == r)
	{
		segTree[x].lazy = -1;
		return;
	}
	int mid = l + r >> 1;
	build(x << 1, l, mid);
	build(x << 1 | 1, mid + 1, r);
	segTree[x].lazy = -1;
}

void update(int x, int l, int r, int val)
{
	if(l <= segTree[x].l && segTree[x].r <= r)
	{
		segTree[x].lazy = val;
		return;
	}
	pushdown(x);
	int mid = segTree[x].l + segTree[x].r >> 1;
	if(r <= mid) update(x << 1, l, r, val);
	else if(l > mid) update(x << 1 | 1, l, r, val);
	else
	{
		update(x << 1, l, mid, val);
		update(x << 1 | 1, mid + 1, r, val);
	}
}

void query(int x, int l, int r)
{
	if(segTree[x].l == segTree[x].r)
	{
		if(segTree[x].lazy != -1)
		{
			if(!vis[segTree[x].lazy])
			{
				cnt ++;
				vis[segTree[x].lazy] = true;
			}
		}
		return;
	}
	pushdown(x);
	int mid = l + r >> 1;
	query(x << 1, l, mid);
	query(x << 1 | 1, mid + 1, r); 
}

int main()
{
	int T;
	scanf("%d", &T);
	while(T --)
	{
		int n;
		memset(vis, false, sizeof(vis));
		cnt = 0;
		int tmp = 1;
		scanf("%d", &n);
		for(int i = 1; i <= n; i ++)
		{
			scanf("%d%d", &L[i], &R[i]);
			H[tmp ++] = L[i];
			H[tmp ++] = R[i];
		}
		sort(H + 1, H + tmp);
		int size = unique(H + 1, H + tmp) - H - 1;
		build(1, 1, size);
		int tl, tr;
		for(int i = 1; i <= n; i ++)
		{
			tl = lower_bound(H + 1, H + size + 1, L[i]) - H;
			tr = lower_bound(H + 1, H + size + 1, R[i]) - H;
			update(1, tl, tr, i);
		}
		query(1, 1, n);
		printf("%d\n", cnt);
	}
	return 0;
}
使用MATLAB和Simulink来创建一个智能家居照明控制系统的仿真模型 智能家居中的智能照明控制系统旨在通过自动化手段优化家庭照明,提高能源效率和居住舒适度。这通常涉及传感器(如光敏传感器、运动传感器)、控制器(如微控制器或PLC)以及执行器(如调光器或开关)。在这个教程中,我们将使用MATLAB和Simulink来创建一个智能家居照明控制系统的仿真模型。 阅读详情

相关推荐

别再手动建模了!用Simscape Multibody Link一键导入SolidWorks装配体到Simulink

本文介绍了如何利用Simscape Multibody Link插件将SolidWorks装配体一键导入Simulink,实现CAD到仿真的无缝衔接。该技术显著提升机械系统设计与控制效率,特别适用于工业机器人、车辆悬架等复杂机构的动力学分析。文章详细解析了插件安装、模型导出优化及仿真验证的全流程,帮助工程师摆脱手动建模的低效工作模式。

weixin_27256197的博客 457

poj 2528 Mayor's posters

线段树+离散化处理。 写的我好蛋疼啊!!! 不过总算过了。 /* POJ: 2528 Mayor's posters */ #include #include #include #include #include #include #include #include #include #include #include using namespace std; c

stormdpzh的专栏 460

QWEN 2.5模型结构解析与代码解读

对Qwen2.5大模型的代码进行研究

4362

poj2528Mayor's posters(线段树)

最近此题根本没有什么卡点,从昨天晚上开始

u010839163的专栏 569

【关于四足机器人那些事】足端轨迹规划-八次多项式轨迹

系列文章目录 文章目录系列文章目录前言一、多项式曲线二、八次多项式曲线总结 前言 在四足机器人的研究中,有一个很关键的问题,就是如何减少足端在触地瞬间的冲击,避免把机器人把自己给蹬倒了?这时候就需要一个合理的足端轨迹规划。本篇将会介绍几种足端轨迹。 本文将对四足机器人的足端轨迹进行规划。将数学中的复合摆线和多项式曲线引入到足端轨迹的规划中,根据零冲击原则[2],规划出 3 条满足要求的足端轨迹,包括: 复合摆线轨迹 八次多项式轨迹 分段五次多项式轨迹 本篇先介绍 - 八次多项式轨迹 一、多项式曲

LiuZ的博客 2955

Android 11.0 app添加校验锁(输入密码才能进入app)

11.0定制化开发中客户要求给app添加锁,就是点击app 图标时,会弹出Dialog,需要输入密码才能进入app中,就是应用校验锁, 最开始想到在Launcher3中实现,但是如果更换了默认Launcher 又不行了 所以最终还是得拦截app启动Activity 从这里入手了 Launcher与APP是在两个不同的进程中,他们之间的通信是通过Binder完成的,点击Launcher上的某个APP,这时会调用Launcher的startActivitySafely方法。 public boolean sta

安卓兼职framework和app工程师的博客 1952

Mayor's posters poj 2528

题目链接:http://poj.org/problem?id=2528 题目大意:贴海报,可以互相覆盖,问贴完所有海报最后能看到几张海报。 先离散化然后用线段树求解即可。 代码: #include #include #include using namespace

凌风 1384

Windows 11 WSL2环境下OpenClaw部署的兼容性问题分析与解决方案研究

本文研究了OpenClaw在Windows 11 WSL2环境下的部署方案。WSL2通过无缝集成Linux与Windows系统,为OpenClaw提供了良好的运行环境,支持GPU加速和跨平台开发。文章详细分析了硬件配置要求(推荐8核CPU/16GB内存/NVMe SSD)、系统选择(Windows 11 Pro+Ubuntu 22.04)以及部署步骤,包括WSL2启用、Linux发行版安装、Python/Node.js/Redis等依赖配置。通过优化.wslconfig文件参数(如内存分

博客 2279

POJ2528——Mayor's posters

题目链接:Mayor’s posters 推荐博客:【完全版】线段树(转载) 题目: 在墙上贴海报,海报可以互相覆盖,问最后可以看见几张海报(后面贴的海报覆盖前面的) 分析: 离散化要保存所有需要用到的值,排序后,分别映射到1~n,这样复杂度就会小很多很多 而这题的难点在于每个数字其实表示的是一个单位长度(并且一个点),这样普通的离散化会造成许多错误 代码: #include<stdio.h...

浦柳人的博客 372

一文吃透 OData Deep Insert:从框架原理到 ABAP 实战

本文面向ABAP工程师,解析OData服务中的Deep Insert技术。文章首先阐述Deep Insert的业务背景,说明其适用于父子层级数据必须成组创建的场景(如销售订单与行项目)。随后深入框架实现机制,介绍SAP Gateway如何通过CREATE_DEEP_ENTITY方法处理嵌套请求,并强调开发者的责任边界。通过销售订单案例,文章对比了Deep Insert与$batch的适用场景差异,提供请求负载示例和DPC_EXT实现骨架代码。最后给出MPC_EXT声明深结构的三种套路,以及事务处理和错误处理

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 225

Cadence OrCAD Capture软件启动过程卡死且无法恢复的解决方法

如下图所示Cadence OrCAD Capture软件在启动后出现卡死的现象,且等待后无法自动恢复,需要强行关闭,再次启动依然卡死。

fydar的博客 4042

POJ.2528 Mayor's posters (线段树 区间更新 区间查询 离散化)

POJ.2528 Mayor’s posters (线段树 区间更新 区间查询 离散化)题意分析贴海报,新的海报能覆盖在旧的海报上面,最后贴完了,求问能看见几张海报。最多有10000张海报,海报左右坐标范围不超过10000000。 一看见10000000肯定就要离散化了,因为建树肯定是建不下。离散化的方法是:先存到一个数组里面,然后sort,之后unique去重,最后查他离散化的坐标lower_bo

Pengwill's Blog 332

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

poj2528-Mayor's posters的树堆解法

二叉搜索树的有序性质使得查找操作时间时长为O(log N),而不需要遍历整个数组。但是如果二叉搜索树退化为单链程序效率会快速下降,因此出现了一些方法使得二叉搜索树趋向平衡,treap也是其中较为简单的一种。         树堆在普通二叉搜索树的每个节点上新增了一个随机数,每次在二叉搜索树插入一个节点后,进行左旋或者右旋使之满足堆序性质,值得注意的是,这个随机数仅仅是为了是树趋向平衡,本身可

陈杰的专栏 549

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

POJ2528-Mayor's posters

全解题报告索引目录 -> 【北大ACM – POJ试题分类】 转载请注明出处:http://exp-blog.com ------------------------------------------------------------------------- 大致题意: 有一面墙,被等分为1QW份,一份的宽度为一个单位宽度。现在往墙上贴N张海报,每张海报的宽度是任意...

ζёСяêτ - 小優YoU 1万+

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

POJ2528 Mayor's posters

POJ上这道题的数据据说很弱,导致很多实际上错误的代码都

那些年我们切过的题 871

POJ - 2528 Mayor's posters(区间覆盖,离散化)

POJ - 2528 Mayor’s posters 题目 给出 n 段区间,区间按给出的顺序会覆盖掉前面的区间,问最后能看到多少不同的区间。 分析 这题只需要用到懒惰标记即可,线段树没有维护什么东西,有懒惰标记 c 代表这个区间被 c 覆盖了。 只不过要用到离散化,题目给出的数据我们只在乎他们的相对大小,相对大小才会影响到区间覆盖的结果 。 通常离散化的时侯是离散到连续的区间,但是有问题,比如数...

Stormjing的博客 311

POJ-2528-Mayor's posters

POJ-2528-Mayor’s posters 传送门 这道题线段树。离散化。二分。 题目大意:一块宣传栏,贴不同颜色的海报,宽度与宣传栏等宽,长度不等,给出长度区间表示,用后者覆盖前者,问最后能见几种颜色的海报 这道题规模1e7。普通的二叉树肯定会超空间。。 思路如下: 离散化: 提取海报的端点,sort去重。把原来的端点映射到新的线段上即可。压缩完成。 然后端点修改。这里二分查找原顺序所在的...

qq_44624316的博客 158

Mayor's posters (POJ-2528)

Mayor's posters (POJ-2528) The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. Th...

菜鸡的博客 361

POJ 2528 ——Mayor's posters

  Time limit 1000 ms Memory limit 65536 kB Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral ...

天际苍穹的博客 251

poj2528——Mayor's posters

题目大意:一面墙分为若干段,现在往墙上贴海报,每张海报占据墙上的一些段,海报可以重叠,问最终露出来的海报个数(完全或者部分露出来都算) 输入:(可以有很多个case)             case个数             海报张数n(1             第i张海报的左起点li  右终点ri(1 i  输出:可见的海报个数 分析: 代码:转载自

tzyshiwolaogongya的博客 252

POJ 2528 Mayor's posters 题解

http://poj.org/problem?id=2528

Twilightuse93的专栏 536
上一篇: ZOJ 1610 Count the Colors
下一篇: 数学建模第一次模拟
剑气扬名
博客等级 码龄7年 24粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值