1,题目大意:
给n条线段,要求划分成尽可能少的子集,使得在同一个子集中的线段两两不重叠.
同时限定线段1和线段2不能在同一子集中.
2,问题分析:
(1)
记每条线段为[Li,Ri], 每个子集的最右端为Bi.
记线段1和2中,L较小的那个为X,另一个为Y.
(2)
如果没有那个限定,容易想到贪心的方法:
将所有线段按L从小到大排序.然后依次处理线段k,如果当前存在某个集合的Bi<=Lk,就将Lk加入此集合中,并更新Bi=Rk.否则新开一个集合放入k.模拟这个过程,最后的集合数就是答案.用堆维护已有集合的信息,时间复杂度是O(nlgn).
(3)
有了限制条件后,原方法不适用了,因为在X与Y之间处理的线段,对B有后效性.这会使得单纯按照刚才的方法随意贪心,可能轮到Y时,只有X所在集合的Bi<=LY,迫使必须开新集合.但实际上,有可能可以通过调整X与Y之间的线段排列结构,使Y避开X.
问题关键就是如何判断能否调整(并不用关心详细的调整步骤).
当一条线段(P)面临多个可插入的集合时,之前的方法是随意选一个,而不合适的决策正在此产生.下面构造一个情景:
假设P可以在两个集合s,t中选择,而X在s中.
现在P选择加入t.
接下来按部就班地处理.
轮到Y选时,它只能选择加入s,或者开新的集合.
这时候,我们能得知,如果当初P选择的是s,紧随其后的其它选择也相应地对调,那么Y此时肯定面临的是只能加入t,或者开新的集合.
这样Y当然直接加入t就行了.
这说明,只要存在一个这样的P,当Y遭遇X时,肯定存在形状对称的另一个局面使Y避开X,而P就是关键先生.
(4)
所以只需稍微改造之前的算法,在处理X与Y之间的线段时,判断并记录下是否出现过可选局面.这样就能正确处理Y遭遇X的情形了.
其它情形时策略不变(可以证明这样的解是最优的).
题目连接:
http://acm.scs.bupt.cn/onlinejudge/showproblem.php?problem_id=1517
分享到:
相关推荐
This second edition of the Essentials version is based on the recent...professors who want a shorter text and do not cover all the topics in the ninth edition.The new second edition of Essentials will be...
Applications follow, starting with the simplest ones (two-level systems, the harmonic oscillator, etc.), and becoming gradually more complicated (the hydrogen atom, approximation methods, etc.)....
Artificial neural networks may probably be the single most successful technology in the last two decades which has been widely used in a large variety of applications. The purpose of this book is to ...
例如:“Good morning, my dear teachers, my dear professors. I am very glad to be here for your interview. My name is Song Yonghao, I am 22 years old...” 总的来说,一个成功的英语自我介绍应该简洁明了...
published by CRC Press LLC, the other two being the Dictionary of Material Science and High En- ergy Physics and Dictionary of Geophysics, Astrophysics and Astronomy. Each of these dictionaries is ...
1. **开场问候**:例如:“Good morning/afternoon, dear teachers/professors. I am very glad to be here for this interview.” 2. **基本信息介绍**:如姓名、年龄、毕业院校等。 3. **教育背景**:详细介绍自己...
- 示例:"Good morning/afternoon, Professors. It’s a fine day today, and I’m very pleased to meet you here." - **个人基本信息**:接着介绍自己的姓名、年龄、出生地等基本信息。 - 示例:"My name is ***...
一个好的开场白能够迅速吸引考官的注意力,比如:“Good morning, respected professors. I am deeply honored to have this opportunity to introduce myself in this prestigious institution.” 2. 基本信息: ...
this book is ideal for students, teachers, professors, novices or average programmers, or for anyone who wants to start learning or teaching computer programming using the proper conventions and ...
首先,自我介绍通常以礼貌的问候开始,例如“Good afternoon, my dear professors”。这样的开场白既显得尊重,又能迅速建立良好的第一印象。 接下来是个人基本信息的介绍:“My name is XXX, 23 years old. I come...
- **开场白**:“Good morning, dear teachers and professors. I am very glad to be here for this interview.” 在正式开始自我介绍之前,礼貌地向考官们问好是非常必要的。这不仅能够营造一个良好的第一印象,还...
Your professors?"):通过他人的评价来评估应聘者的性格特点和工作态度。 5. **自我展示**(如"What else should I know about you?"):提供一个机会让应聘者展示自己的独特性,包括个人优势和兴趣爱好。 6. **...
4. 公共交通服务:"A new regular bus service to Tianjin Airport started to operate two months ago." 表示开通了一条定期的公交线路,"regular" 指定期、定时。 5. 基础、依据:"We drew this conclusion on ...
- “What two or three things are important to you in your new position?”:考察价值观与职位的契合度。 5. **离职原因与忠诚度** - “Why do you want to leave your current position?”:理解应聘者的离职...
The lecture is part of the course CS101, taught by Professors Dengji Zhao and Yuyao Zhang. #### What Will We Learn from This Course? The course aims to provide a comprehensive understanding of ...
Your professors?) - 这是评估你的个人特质和人际交往能力的机会,可以提及团队合作、沟通技巧和专业素养等正面评价。 5. **我还需要知道关于你的哪些事情?**(What else should I know about you?) - 这是...
#### (g) One can travel between any two Canadian cities by airplane, train, or bus. 这个句子的谓词逻辑形式为:∀x∀y(P(x)∧P(y)→(Q(x,y)∨R(x,y)∨S(x,y))),这里P(x)代表“x是加拿大城市”,Q、R、S分别...
6. **参与项目与荣誉**:列举参与的科研项目,如“participating in the research of two projects funded by National Natural Science Foundation”,并提及获得的奖励,如“rewarded the Excellent Prize”。...
Your professors?** - **考察点**:评估应聘者的个性特点和社会评价。 - **应对策略**:选择正面积极的形容词,例如“可靠”、“勤奋”等,并提供具体例子加以佐证。 **5. What else should I know about you?** -...