贪心-poj-2437-Muddy roads】的更多相关文章

题目链接:https://vjudge.net/contest/194475#problem/C 题目大意: 有n滩泥 木板长度为L 求至少需要多少木板才能覆盖这些泥 解题思路: 把泥块的起点升序排序,分三种情况讨论 1.前一个木板完全覆盖了当前的泥 跳过 2.前一个木板覆盖了一部分 则计算铺完剩下的泥需要多少木板 3.前一个木板完全没接触到当前的木板 则更新端点 #include <cstdio> #include <cstring> #include <algorithm…
P1589 [Usaco2005 Open] Muddy roads 泥泞的路 简单的模拟题. 给水坑排个序,蓝后贪心放板子. 注意边界细节. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ]; bool cmp(const data &A,const data &B){ return A.l<…
1689: [Usaco2005 Open] Muddy roads 泥泞的路 Description Farmer John has a problem: the dirt road from his farm to town has suffered in the recent rainstorms and now contains (1 <= N <= 10,000) mud pools. Farmer John has a collection of wooden planks of…
poj   1251  Jungle Roads  (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23507   Accepted: 11012 Description The Head Elder of the tropical island of Lagrishan has a problem. A b…
POJ 3411 Paid Roads Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6553   Accepted: 2430 Description A network of m roads connects N cities (numbered from 1 to N). There may be more than one road connecting one city with another. Some o…
1689: [Usaco2005 Open] Muddy roads Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 147  Solved: 107[Submit][Status][Discuss] Description Farmer John has a problem: the dirt road from his farm to town has suffered in the recent rainstorms and now contai…
HDU 1815, POJ 2749 Building roads pid=1815" target="_blank" style="">题目链接HDU 题目链接POJ 题意: 有n个牛棚, 还有两个中转站S1和S2, S1和S2用一条路连接起来. 为了使得随意牛棚两个都能够有道路联通,如今要让每一个牛棚都连接一条路到S1或者S2. 有a对牛棚互相有仇恨,所以不能让他们的路连接到同一个中转站. 还有b对牛棚互相喜欢,所以他们的路必须连到同一个中专站.…
POJ 2226 Muddy Fields 题目链接 题意:给定一个图,要求用纸片去覆盖'*'的位置.纸片能够重叠.可是不能放到'.'的位置,为最少须要几个纸片 思路:二分图匹配求最小点覆盖.和放车那题基本一样.就是注意要预处理一下行列,把连续横的'*'当成一行,竖的'*'当成一列,建图跑最小点覆盖就可以 代码: #include <cstdio> #include <cstring> #include <vector> #include <algorithm&g…
http://www.lydsy.com/JudgeOnline/problem.php?id=1689 一开始我也想到了贪心,,,策略是如果两个连续的水池的距离小于l的话,那么就将他们链接起来,,,然后全部操作完后直接在每个大联通块上除以长度然后取木板就行了.. 但是不知道哪里错了T_T 正解:放木板尽量往后放.证明:假设当前i有水池,i-1没有水池,因为长度是固定的,那么从i放显然由于从i-1放木板. 然后模拟放木板即可. 优化:算出每个连续的水池需要放的数量,然后加上即可 #include…
按左端点排序,贪心的选即可 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=10005; int n,l,p,ans; struct qwe { int x,y; }a[N]; bool cmp(const qwe &a,const qwe &b) { return a.x<b.x; } int read() { int…