Mayor's posters--------线段树

【离散化 线段树 逆向思考】P3740 [HAOI2014] 贴海报|普及+ 贴海报 ## 题目描述 Bytetown 城市要进行市长竞选,所有的选民可以畅所欲言地对竞选市长的候选人发表言论。为了统一管理,城市委员会为选民准备了一个张贴海报的 electoral 墙。 张贴规则如下: 1. electoral 墙是一个长度为 $N$ 个单位的长方形,每个单位记为一个格子; 2. 所有张贴的海报的高度必须与 electoral 墙的高度一致的; 3. 每张海报以 `A B` 表示,即从第 $A$ 个格子到第 $B$ 个格子张贴海报; 4. 后贴的海报可以覆盖前面已贴的海报 阅读详情
Mayor's posters           438ms
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 15106 Accepted: 4224

Description

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
竞选海报(线段树加离散化) 利用线段树以及离散化的思想解决竞选海报问题。 立即下载

相关推荐

在LinuxMint 22.1(Ubuntu24.04)上安装使用同花顺远航版

Linux用户成功在LinuxMint22.1系统上通过Wine9.0运行同花顺远航版,解决了长期困扰的股票行情软件问题。此前Linux原生版同花顺功能简陋且停止更新,Wine版通达信存在显示问题。作者作为自由软件支持者,通过调整Wine配置文件解决了高分屏显示异常问题,实现了远航版的正常使用。期待同花顺能重启Linux原生版开发,支持更多处理器架构,完善国产软件生态。该方案为Linux股票软件用户提供了实用参考。

5134

【UE4】UE4联级粒子系统

一、粒子系统的一些基本概念 1.Particle System(粒子系统) 粒子系统如同贴图、模型一样属于UE4的驻留资产,不能单独存在于场景中,必须使用载体依托才能在场景中渲染出来,粒子系统包含粒子特效的所有配置。粒子系统在UE4中表现为如下样子: 创建粒子系统 在内容浏览器中右键选择Particle System可以直接创建粒子系统。 2.Emitter Actor(粒子发射器) 粒子发射...

Goulandis 7976

Aitoearn内容营销的最佳开源 AI 代理,创建 · 发布 · 互动 · 副业一站式平台,支持渠道:抖音、小红书(红点)、微信通道、快手、哔哩哔哩、微信公众号、抖音等等

Aitoearn内容营销的最佳开源 AI 代理,创建 · 发布 · 互动 · 副业一站式平台,支持渠道:抖音、小红书(红点)、微信通道、快手、哔哩哔哩、微信公众号、抖音等等

struggle2025的博客 1749

POJ 2528 Mayor's posters(离散化 线段树 贴海报)

题意  在墙上贴n张海报  输入每张海报的的左右端点坐标  问最后可以看到多少张海报  能看到一点也是能看到 先把线段树初始化为0 输入一张海报  就把那个区间变成这张海报的序号  最后判断墙上有多少个不同的序号就行了 但是海报坐标的端点值高达10000000  直接用线段树会超时   但是注意到海报最多只有10000张  也就是最多有20000个不同的坐标  于是可以利用离散化的知识   把

Deng's site \# 2142

使用Transformer实现自动调制识别(RML2018)

image_size = 1024 # resize重置输入大小patch_size = 16 # 从输入图片中将被提取的块大小# 分成 num_patches 个块num_patches = (image_size // patch_size) #(72/6)**2 横着裁剪),],return x})

QAQIknow的博客 1321

Android 车联网——CarAudioService介绍(六)

CarAudioService 是 Android Automotive OS 中的一个重要组件,用于管理车辆中的音频功能。它是 Android Auto 的一部分,负责处理车辆音频的播放、控制和路由。CarAudioService 使用标准的 Android 组件架构,基于 Binder 通信机制,提供了一组 API,用于管理车辆音频。它包括以下主要功能:音频路由管理:CarAudioService 可以让开发者控制音频的路由,即将音频发送到不同的输出设备,例如车辆的扬声器、耳机等。

小旭的专栏 3201

ue4加速度_【ue4】ue4联级粒子系统

1.Particle System(粒子系统)粒子系统如同贴图、模型一样属于UE4的驻留资产,不能单独存在于场景中,必须使用载体依托才能在场景中渲染出来,粒子系统包含粒子特效的所有配置。粒子系统在UE4中表现为如下样子:创建粒子系统在内容浏览器中右键选择Particle System可以直接创建粒子系统。2.Emitter Actor(粒子发射器)粒子发射器就是粒子系统的载体,粒子发射器承载粒子系...

weixin_29688227的博客 976

jieba分词

jieba

sikh_0529的博客 1万+

PKU 2528 (线段树 + 离散化)

Mayor's postersTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14306 Accepted: 3997<br />DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at al

-- bird -- 952

FAA机载电子硬件审查指南详解(评审和审查必备)

本咨询通告旨在协助认证机构、授权代表(包括组织授权)和申请人执行机载电子硬件评审(以下简称"硬件评审")。硬件评审的目的是评估机载电子硬件是否符合适航要求和建议的符合性方法(即RTCA/DO-254)。本工作辅助文件应作为评审过程中的参考工具使用。它不应被用作检查表,也不包含所有可能需要评审的情况。同样,本工作辅助文件也不是用来替代DO-254,而应与DO-254一起使用。此外,本工作辅助文件可能包含一些不适用于特定项目评估的问题。

qq_41854911的博客 610

深入大模型-19-Windows10中安装OpenClaw-CN配置接入智谱免费大模型

OpenClaw CN (中国社区版) 是 OpenClaw 的本地化维护版本,针对国内网络环境进行了深度优化,源码级原生支持 DeepSeek/Qwen 等国产大模型,致力于让中国开发者拥有最顺滑的 Agent 开发体验。

qq_20466211的博客 771

poj2528Mayor's posters(线段树)

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

u010839163的专栏 569

单片机原理及应用知识点汇总(一)

在键闭合稳定时,读取键的状态,并且必须判别;、串行通信的优点是只需一对传送线,成本低,适于远距离通信,缺点是传送速度较低。、并行通信的优点是传送速度高,缺点是所需传送线较多,远距离通信不方便。、串行通信中,为使设备同步工作,需要通信双方有两个共同的要求,一是。系列单片机的指令中,既有带借位的减法指令,又有不带借位的减法指令。、简述在使用普通按键的时候,为什么要进行去抖动处理,如何处理。、在异步通信的帧格式中,数据位是低位在前高位在后的排列方式。、异步通信中,波特率是指每秒传送二进制代码的位数,单位是。

T19900的博客 696

POJ2528 Mayor's posters 线段树

POJ 2528 Mayor's posters 线段树Mayor's postersTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 39344Accepted: 11424DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in ...

我是谁 --- 卡比兽 170

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

UVA10587 Mayor's posters【线段树】

translate 按照顺序向一面墙上贴n张海报,海报会互相覆盖,求最后可以看得到的海报张数 analysis 别样的线段树 要维护的是某个区间颜色的种类数 但这个题是所有操作完后才进行询问,所有可以只维护区间左边的颜色种类和右边的颜色种类,在最后的时候对于每一个长度为1的区间进行一次询问,询问其颜色种类即可 由于大区间的l,r和小区间的l,r有关系,所以可以维护(其实区间颜色个数好像也可以维...

AndrewLi的博客 217

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

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

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

Pengwill's Blog 332

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

【線段樹】Mayor's posters

Description 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

void* ptr = &OI; 1183

【线段树】Mayor's posters

描述 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 final...

weixin_38281074的博客 332

Mayor's posters【线段树】

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....

C++的星空 289

线段树 G - Mayor's posters

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 d...

weixin_30384031的博客 103

Mayor's posters 线段树+离散化+桶

简单说下题意:就是在一个宽1e7墙上面贴n张海报,第i张海报的起点是li,终点是ri,显然海报会覆盖别的海报。问依次贴完n张海报之后最后能看见几张海报。 题目要求最后能看见多少张海报,那么我们将每张海报都分别标上序号1,2,3…n。然后线段树修改区间,最后看线段树最底层有多少种数字即可。 需要注意的几点: 海报终点可能到1e7,我们要做的区间修改以及最后桶排计数工作量就会非常大,但是只有...

陈颜的博客 5267

【线段树+离散化】Mayor's Posters

Poj2528 Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23573   Accepted: 6828 Description The citizens of Bytetown, AB, could not

wu_yihao的专栏 718

POJ 2528 Mayor's posters 【区间离散化+线段树区间更新&&查询变形】

任意门:http://poj.org/problem?id=2528 Mayor's posters Time Limit:1000MS Memory Limit:65536K Total Submissions:77814 Accepted:22404 Description The citizens of Bytetown, AB, could n...

Mod_13的博客 185

POJ Mayor's posters 线段树

在此给出一组测试数据, 1 3 1 10 1 3 6 10 答案是:3 错的不知所以,重写才能过系列。 传送门:http://poj.org/problem?id=2528 #include #include #include #include #include #include #include #include using namespace std;

NM的专栏 388

C++模板进阶:非类型参数、特化与分离编译实战解析

模板是C++泛型编程的核心机制,但多数开发者仅停留在类型参数化层面。真正进阶的关键在于理解模板参数不仅可以是类型,还可以是编译期常量(非类型模板参数),这使代码能在编译期完成定长容器设计、常量化计算等优化。模板特化则为特定类型或条件提供定制实现,是类型萃取与策略分发的基础。而分离编译机制决定了模板代码在工程中如何组织,避免常见的undefined reference错误。从基础模板语法到多文件工程实践,掌握非类型参数、特化与分离编译的协同原理,能显著提升代码的灵活性与性能,为深入阅读STL源码与构建大型项目

weixin_34344403的博客 299

Mayor's posters 线段树+离散化

题目地址:http://poj.org/problem?id=2528 首先第一行要输入c,表示进行c个测试案例。题意大体是有n(1 <= n <= 10000)个人往墙上贴海报,每个人给出贴的范围li,ri(1 <= li<= ri <= 10000000),问最后还能看见多少海报(完整的不完整的都算). 先说一下什么是离散化,如果线段树要开的区间...

zhangjinlei321的博客 179
上一篇: Square Coins-------母函数,多项式相乘
下一篇: cout,cin和printf()及scanf()的比较。-------------Mobile phones---------树状数组
includeiostream123
博客等级 码龄16年 34粉丝 32原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值