题目描述 Farmer John recently opened up a new barn and is now accepting stall allocation requests from the cows since some of the stalls have a better view of the pastures. The barn comprises N (1 <= N <= 100,000) stalls conveniently numbered 1..N; stal…
[题解] 贪心. 把区间按照右端点从小到大排序,右端点相同的按照长度从小到大排序,然后按顺序考虑,能放就放下去. 维护能不能放下去用线段树即可. #include<cstdio> #include<cstring> #include<algorithm> #define LL long long #define rg register #define N 100010 #define ls (u<<1) #define rs (u<<1|1) u…
传送门 解题思路 扫了一眼觉得是贪心+线段树,结果贪心的时候刚开始按区间长度排的序..这还有82分,后来叉了自己,换成按右端点排序过了. 代码 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int MAXN = 100005; inline int rd(){…
[USACO10MAR]仓配置Barn Allocation 思路: 贪心+线段树维护: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #define INF 0x3f3f3f3f #define maxtree maxn<<2 struct QueryType { int l,r; bool operator<(const QueryType pos)const { if(pos.…
题目描述 Bessie is planning the annual Great Cow Gathering for cows all across the country and, of course, she would like to choose the most convenient location for the gathering to take place. Each cow lives in one of N (1 <= N <= 100,000) different ba…
P2986 [USACO10MAR]伟大的奶牛聚集Great Cow Gat… 题目描述 Bessie is planning the annual Great Cow Gathering for cows all across the country and, of course, she would like to choose the most convenient location for the gathering to take place. Each cow lives in on…
题目描述 Bessie is planning the annual Great Cow Gathering for cows all across the country and, of course, she would like to choose the most convenient location for the gathering to take place. Bessie正在计划一年一度的奶牛大集会,来自全国各地的奶牛将来参加这一次集会.当然,她会选择最方便的地点来举办这次集会…
题目描述It's milking time at Farmer John's farm, but the cows have all run away! Farmer John needs to round them all up, and needs your help in the search. FJ's farm is a series of N (1 <= N <= 200,000) pastures numbered 1...N connected by N - 1 bidirec…
题目传送门 逃跑的Barn 题目描述 It's milking time at Farmer John's farm, but the cows have all run away! Farmer John needs to round them all up, and needs your help in the search. FJ's farm is a series of N (1 <= N <= 200,000) pastures numbered 1...N connected b…
P6183 [USACO10MAR]The Rock Game S 输入输出样例 输入 3 输出 OOO OXO OXX OOX XOX XXX XXO XOO OOO PS: 因为每一位只有两种可能,这里用01,有没有重复的,就可以把01转换成十进制, 看看有没有用过,知道找出所有 Java代码:90分还望大佬指点 import java.util.Scanner; public class TheRockGame { public static int n=0,max=0;; public…