[USACO12FEB]Overplanting S】的更多相关文章

一种矩形切割的做法: 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 const int maxn=1005; 5 struct node{//矩形的结构体 6 LL x1,y1,x2,y2; 7 }a[maxn]; 8 int n,cnt=0; 9 10 void Cut(LL id,LL x1,LL y1,LL x2,LL y2){//矩形切割 11 LL k1,k2,k3,k4; 12…
Description 在一个笛卡尔平面坐标系里(则X轴向右是正方向,Y轴向上是正方向),有\(N(1<=N<=1000)\)个矩形,第i个矩形的左上角坐标是\((x1, y1)\),右下角坐标是\((x2,y2)\).问这\(N\)个矩形所覆盖的面积是多少?注意:被重复覆盖的区域的面积只算一次. Input 第一行,一个整数N. \((1<=N<=1000)\). 接下来有\(N\)行,每行描述一个矩形的信息,分别是矩形的\(x1.y1.x2.y2\). 其中 \(−10^8&l…
什么,扫描线需要线段树? 那我第一个不干啊(其实是不会写) 这里介绍一种裸的扫描线: 我们根据x排序,对于相等的 \(x\) ,将 \(y\) 进入和退出分类讨论,然后全部放进set里面.每次 \(x\) 不相等的时候,答案就是 (现在y覆盖的乘以(现在的x-以前的x)) 具体的判断方法: 1.y的判断: 将每个长方形的上方点记做出口,下方点记做入口.用一个set记录在某区间内所有的 \(y\) 值.每次从下往上扫,如果某个y是入口就将 \(sz\) +1,否则就将 \(sz\) -1.如果 \…
P3048 [USACO12FEB]牛的IDCow IDs 12通过 67提交 题目提供者lin_toto 标签USACO2012 难度普及/提高- 时空限制1s / 128MB 提交  讨论  题解 最新讨论更多讨论 谁能解释一下这个样例啊.... 题目描述 Being a secret computer geek, Farmer John labels all of his cows with binary numbers. However, he is a bit superstitiou…
P3047 [USACO12FEB]附近的牛Nearby Cows 农民约翰已经注意到他的奶牛经常在附近的田野之间移动.考虑到这一点,他想在每一块土地上种上足够的草,不仅是为了最初在这片土地上的奶牛,而且是为了从附近的田地里去吃草的奶牛. 具体来说,FJ的农场由N块田野构成(1 <= n <= 100,000),每两块田野之间有一条无向边连接(总共n-1条边).FJ设计了农场,任何两个田野i和j之间,有且只有一条路径连接i和j.第 i块田野是C(i)头牛的住所,尽管奶牛们有时会通过k条路到达其…
P3045 [USACO12FEB]牛券Cow Coupons 71通过 248提交 题目提供者洛谷OnlineJudge 标签USACO2012云端 难度提高+/省选- 时空限制1s / 128MB 提交  讨论  题解 最新讨论更多讨论 86分求救 题目描述 Farmer John needs new cows! There are N cows for sale (1 <= N <= 50,000), and FJ has to spend no more than his budget…
P3047 [USACO12FEB]附近的牛Nearby Cows 题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into account, he wants to plant enough grass in each of his fields not only for the cows situated initially in that field, but…
P3047 [USACO12FEB]附近的牛Nearby Cows 题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into account, he wants to plant enough grass in each of his fields not only for the cows situated initially in that field, but…
[USACO12FEB]牛券Cow Coupons(堆,贪心) 题目描述 Farmer John needs new cows! There are N cows for sale (1 <= N <= 50,000), and FJ has to spend no more than his budget of M units of money (1 <= M <= 10^14). Cow i costs P_i money (1 <= P_i <= 10^9), b…
P3045 [USACO12FEB]牛券Cow Coupons 贪心题.先选中 \(c_i\) 最小的 \(k\) 头牛,如果这样就超过 \(m\) ,直接退出,输出答案.否则考虑把后面的牛依次加入,替换前面用过券的牛.这里贪心得选择省钱最少的牛替换掉(这样影响最小,最有可能多买几头).加入牛的顺序按照 \(p\) 从小到大,因为如果换不掉就只能话 \(p\) 的钱去买 #include<bits/stdc++.h> using namespace std; #define int long…