BZOJ1689: [Usaco2005 Open] Muddy roads】的更多相关文章

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…
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 length L that he can use to bridge these…
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…
水题,模拟就行了,别忘了L>=r的时候直接更新下一个的L然后continue type node=record l,r:longint; end; var n,l,i,ans:longint; k:array[..] of node; function ma(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; procedure qs(t,w:longint); var mid,l,r:longint; tem:…
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…
链接 1735: [Usaco2005 jan]Muddy Fields 泥泞的牧场 思路 这就是个上一篇的稍微麻烦版(是变脸版,其实没麻烦) 用边长为1的模板覆盖地图上的没有长草的土地,不能覆盖草地 每个点(x,y)只有选择x或者y才能被覆盖 还是最小点覆盖,证明在上一篇 横边和竖边得遍历一遍求出,因为不能越过草地嘛 然后左边横边,右边竖边,开心的跑最大流就可以 代码 #include <bits/stdc++.h> #define iter vector<int>::itera…
题目:http://poj.org/problem?id=2226 题意:给你一个字符矩阵,每个位置只能有"*"或者“.",连续的横着或者竖的“*"可以用一块木板覆盖,"."不能被覆盖,求最少用多少块木板才能把整张图里的"*"全覆盖住 分析:很巧妙的建图 将所有横着的连续的"*"看作二分图左边的点集,同理竖着的连续的"*"看作二分图右边的点集 如果有横着的连续的"*"…
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 length L that he can use to bridge these…