BZOJ4388 : JOI2012 invitation】的更多相关文章

注意到这个过程实质就是prim算法求最大生成树的过程. 首先通过离散化+线段树将$A+B$个点缩为上下各$O(n)$个点. 设已加入集合为$S$,未加入集合为$T$. 建立两棵线段树,维护所有在$T$集合中的点,以及从每个点连出去的边. 用一个大根堆维护所有横跨$ST$的边.每次取出堆顶的边,取出与这条边相连的任意一个属于$T$集合的点,若取不出则将这条边删去:否则将这个点加入$S$,并将所有连了它的边加入堆中. 时间复杂度$O(n\log n)$. #include<cstdio> #inc…
[BZOJ4388]JOI2012 invitation Description 澳洲猴举办了一场宴会,他想要邀请A个男生和B个女生参加,这A个男生从1到A编号,女生也从1到B编号.现在澳洲猴知道n组朋友关系,这n组朋友关系是这样描述的:男生中编号为Pi到Qi的和女生中编号为Si到Ei的是好朋友,这也就是说(Qi-Pi+1)个男生之间互相是好朋♂友,(Si-Ei+1)个女生之间互相是好朋♂友,(Qi-Pi+1)个男生和(Si-Ei+1)个女生之间互相也是好朋友,总之他们互相是好友关系,并且互相的…
Description link Solution 可以发现题目在模拟 Prim 算法求最大生成树的过程,树边故答案与起点 \(C\) 无关. 先把所有区间离散化,注意对于一个区间 \([l,r]\),要把 \(l,l+1,r\) 三个位置提出来离散化,作为所有新区间的左端点,这样总共只有 \(O(n)\) 个新区间.提 \(l+1\) 的原因待会再说. 则从起点 \(C\) 出发,寻找所有覆盖 \(C\) 的区间,将这个区间连向的另一个区间扔进大根堆,键值为边权,并删除这个区间.每次取出大根堆…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
题目链接 https://www.lydsy.com/JudgeOnline/problem.php?id=4388 题解 模拟Prim算法? 原题所述的过程就是Prim算法求最大生成树的过程.于是我们可以知道起始点并没有影响. 那么就用数据结构模拟Prim算法吧. 首先离散化所有区间,每个区间只需要一个点和外面相连,其余点均按照覆盖该点区间的最大权值与这个点相连.因此简单利用线段树即可求出这一部分的答案. 对于剩下的部分,用维护\(T\)表示目前没有加入的点,先加入左边\(1\)号点,同时用大…
题目链接: 传送门 Invitation Cards Time Limit: 5000MS     Memory Limit: 32768 K Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, mo…
Invitation Cards Time Limit : 16000/8000ms (Java/Other)   Memory Limit : 524288/262144K (Java/Other) Total Submission(s) : 7   Accepted Submission(s) : 1 Problem Description In the age of television, not many people attend theater performances. Antiq…
Invitation Cards 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/J Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater a…
Invitation Cards DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed invitatio…
Invitation Cards Time Limit: 8000MS Memory Limit: 262144K Total Submissions: 24460 Accepted: 8091 Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to…