poj 1089 Intervals】的更多相关文章

http://poj.org/problem?id=1089 Intervals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7214   Accepted: 2862 Description There is given the series of n closed intervals [ai; bi], where i=1,2,...,n. The sum of those intervals may be rep…
There is given the series of n closed intervals [ai; bi], where i=1,2,...,n. The sum of those intervals may be represented as a sum of closed pairwise non−intersecting intervals. The task is to find such representation with the minimal number of inte…
Intervals Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %lld & %llu Submit Status Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: reads the number of intervals, their en…
Intervals Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5762   Accepted: 2288 Description You are given N weighted open intervals. The ith interval covers (ai, bi) and weighs wi. Your task is to pick some of the intervals to maximize t…
题意 在区间[0,50000]上有一些整点,并且满足n个约束条件:在区间[ui, vi]上至少有ci个整点,问区间[0, 50000]上至少要有几个整点. 思路 差分约束求最小值.把不等式都转换为>=形式,那么显然有xvi >= xui-1 + ci,那么就在约束图中连一条(ui-1, vi, ci)的边:当然不要忘记隐含的不等式:xi >= xi-1 + 0;   xi-1 >= xi -1. 建完图后SPFA求最长路径即可 代码 [cpp] #include <iostr…
做的第一道差分约束的题目,思考了一天,终于把差分约束弄懂了O(∩_∩)O哈哈~ 题意(略坑):三元组{ai,bi,ci},表示区间[ai,bi]上至少要有ci个数字相同,其实就是说,在区间[0,50000]上,每一个三元组表示[ai,bi]之间至少要标记ci个数字,问至少要标记多少个数字. 在学习差分约束的童鞋,建议看一下:09年姜碧野的<SPFA算法的优化及应用>,06年冯威的<浅析差分约束系统>,不过后者看起来较难搞懂,也可以看http://ycool.com/post/m2u…
题目:http://poj.org/problem?id=1201 题意:给定n组数据,每组有ai,bi,ci,要求在区间[ai,bi]内至少找ci个数, 并使得找的数字组成的数组Z的长度最小. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> using namespace std; <<;…
Intervals Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 20779   Accepted: 7863 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.  Write a program that:  reads the number of intervals, their end…
Intervals Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24099   Accepted: 9159 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: reads the number of intervals, their end po…
Intervals Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7218   Accepted: 3011 Description You are given N weighted open intervals. The ith interval covers (ai, bi) and weighs wi. Your task is to pick some of the intervals to maximize t…
http://poj.org/problem?id=3680 巧妙的构图. 题目:给定N个区间(ai,bi)权值wi,求最大权和且每个点最多覆盖K次. 构图:将区间端点离散化,将第i个点连第i+1个点花费为0,容量为INF,即addedge(i,i+1,0,INF)(可用来跳过一些区间); 再处理N个区间(ai,bi),addedge(ai,bi,-wi,1); 最后源点连第一个点,addedge(src,1,0,k);最后一个点连汇点,addedge(n,sink,0,k). 原理:构完图之后…
开始前先讲几句废话:这个题我开始也没看懂,后来借助百度翻译,明白了大概是什么意思. 试题描述 输入一个n,然后输入n组数据,每个数据有两个数,代表这个闭区间是从几到几.然后看,如果任意两个闭区间有相重的地方,那么就把这两个闭区间合并,最后输出没有合并的闭区间. 试题描述正版 There is given the series of n closed intervals [ai; bi], where i=1,2,-,n. The sum of those intervals may be rep…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1384 Intervals Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4841    Accepted Submission(s): 1815 Problem Description You are given n closed, in…
开始前先讲几句废话:这个题我开始也没看懂,后来借助百度翻译,明白了大概是什么意思. 试题描述 输入一个n,然后输入n组数据,每个数据有两个数,代表这个闭区间是从几到几.然后看,如果任意两个闭区间有相重的地方,那么就把这两个闭区间合并,最后输出没有合并的闭区间. 试题描述正版 There is given the series of n closed intervals [ai; bi], where i=1,2,…,n. The sum of those intervals may be rep…
Time Limit: 2000MSMeamory Limit: 65536K Total Submissions: 27949Accepted: 10764 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.Write a program that:reads the number of intervals, their end points and integer…
题目:http://poj.org/problem?id=1201 差分约束裸套路:前缀和 本题可以不把源点向每个点连一条0的边,可以直接把0点作为源点.这样会快许多! 可能是因为 i-1 向 i 都连着一条0的边. 别忘了约束条件不仅有s[ i ] - s[ i-1 ] >= 0,还有s[ i ] - s[ i - 1] <= 1! 别忘了s的范围不是n而是mx! #include<iostream> #include<cstdio> #include<cstr…
[题目链接] http://poj.org/problem?id=3680 [题目大意] 有N个带权重的区间,现在要从中选取一些区间, 要求任意点都不被超过K个区间所覆盖,请最大化总的区间权重. [题解] 我们将权重取负后进行建图,对于每个区间从首到末连边, 如果该路被增广则说明这个区间被选定,我们只要给定K的流量 最后求出最大流下的最小费用即可 [代码] #include <cstdio> #include <algorithm> #include <cstring>…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 27746   Accepted: 10687 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: reads the number of intervals, their end points and…
POJ 1201 http://poj.org/problem?id=1201 题目大意: 有一个序列,题目用n个整数组合 [ai,bi,ci]来描述它,[ai,bi,ci]表示在该序列中处于[ai,bi]这个区间的整数至少有ci个.如果存在这样的序列,请求出满足题目要求的最短的序列长度是多少. 思路: 设s[i]为从1~i的整数个数. 这样对于区间[ a , b]显然有 S[b+1] - S[a] >=c[i] (为什么是b+1?因为闭区间b也要选上呀) 然后还有 0<= S[B+1]-S[…
传送门:http://poj.org/problem?id=1201 题意: 有n个如下形式的条件:,表示在区间[, ]内至少要选择个整数点.问你满足以上所有条件,最少需要选多少个点? 思路:第一道差分约束题,有关差分约束知识详见https://blog.csdn.net/whereisherofrom/article/details/78922648(个人感觉这个博主写的挺好的) 令表示从区间[0,x]中选择的整数点个数,则有=c_i\rightarrow s_{b_i+1}-s_{a_i}>…
Intervals Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 30971 Accepted: 11990 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: reads the number of intervals, their end point…
给定N个带权的开区间,第i个区间覆盖区间(ai,bi),权值为wi.现在要求挑出一些区间使得总权值最大,并且满足实轴上任意一个点被覆盖不超过K次. 1<=K<=N<=200.1<=ai<bi<=100000.1<=wi<=100000. 最小费用最大流. 将所有区间端点离散化到整数1到M,每个数对应一个点. 源点向整数1点连一条容量为K费用为0的边. 整数i点向整数i+1点连一条容量为正无穷费用为0的边.(1<=i<M). 整数M点向汇点连一条容…
题意:有n个区间[a,b],每个区间有一个值c.找一个集合中的元素使得每个区间至少有c个元素在这个集合中,问最小的集合大小. 思路:设d[i+1]表示0到i有多少个数在这个集合中,显然对于每个区间,d[b+1]-d[a]>=c,才能符合题目的要求.但是这样并不能使得所有集合都联系起来.继续挖掘条件,根据d[]的定义可得,0<=d[i+1]-d[i]<=1. 由此可得三个不等式: d[b+1]-d[a]>=c d[i+1]-d[i]>=0 d[i]-d[i+1]>=-1…
题意: 有一个集合Z,其元素都是整整数,但是数量未知.现有n个约束,形如 [a,b]=c 表示整数区间[a,b]中有c个元素在Z中出现.问集合Z最小可能含多少个元素? 思路: 对于所给的区间 cnt[b-a]>=k这可以保证了该区间内个数不少于k.但是由于两边都是闭区间,所以要变cnt[b-(a-1)]>=k,表示b到a之间的个数.也就是说,转成式子是b-(a-1)>=k,变换一下为(a-1)-b<=-k,就满足常见的式子b-a<=k啦,可以建边b指向(a-1),权值为-k.…
差分约束系统. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<algorithm> using namespace std; ; map<int, int> jz[maxn]; vector<int>ljb[maxn]; int di…
<题目链接> 题目大意:给你$n$段区间,$a_i,b_i,c_i$ 表示在 $[a_i,b_i]$ 区间内至少要选择$c_i$个点.现在问你在满足这n个条件的情况下,最少要选多少个点? 解题分析: 经典的差分约束.本问题需要满足的不等式有:$s[b[i]]-s[a[i]-1]\geq c[i],0\leq s[i]-s[i-1]\leq 1$,其中s[i]表示到第i个位置为止,所选择的点的个数. 转换一下,就能够得到: $s[b[i]]\geq s[a[i]-1]+c[i]$ $s[i]\g…
<题目链接> <转载于> 题目大意: 给一个光源点s,给一些圆,源点和s相切会形成阴影,求每一段阴影在横轴上的区间. 解题分析: 这道其实不需要点与圆切线的板子来求解,完全可以根据角度和线段长度之间的关系计算. 解此题的方法就是,先单独对每一个圆研究,算出它们各自在横轴上的投影区间,然后,再求出这些区间的并,把每一段区间输出即可. 当然,我们应该要注意到,点与圆的位置关系不只有这一种情况,还一种情况是,圆的圆形没有超过垂线,但是圆的圆心X+R超过了垂线,但是,经过简单证明发现,其实…
懒得复制,戳我戳我 Solution: 这道题就是一个板子题 抽象成第\(a\)至第\(b\)间选择数的个数为\(c\),我们就可以用前缀和来表示,这样就可以得到不等式\(s[b]-s[a-1]>=c\),然后就可以差分约束了 这一个约束条件不够,因为每个数只能选择一次,所以补上\(s[i+1]-s[i]>=0\)和\(s[i+1]-s[i]<=1\),注意存在\(0\)与\(-1\)的连边,我们可以吧\(-1\)拿出来用大于\(50000\)的数字来表示 然后求单元最大路径,随后的\(…
#include <iostream> #include <algorithm> #define MAXN 50005 using namespace std; struct node { int x; int y; bool boo; }; bool op(node a,node b); node _node[MAXN]; int main() { //freopen("acm.acm","r",stdin); int i; int j;…
相交区间选尽量少的点是可以贪心的,右端点排序以后,尽量往右边放可以得到可以使得点在区间尽可能多. 但是我只想到了O(n)的维护方法.(数据比较水,能过... 或者是前缀和可以写sum(bi) - sum(ai-1) ≥ ci 再加上前缀和的单调性 sum(i) - sum(i-1) ≥ 0 以及一个点只能选一次 sum(i-1) - sum(i) ≥ -1. 左边具有可加性的,根据对偶性:min ( sum(n) - sum(0) ) ≥ max( c ) 右边就是求一个最长路了. 复杂度:O(…