P3068 [USACO13JAN]派对邀请函Party Invitations 题目描述 Farmer John is throwing a party and wants to invite some of his cows to show them how much he cares about his herd. However, he also wants to invite the smallest possible number of cows, remembering all t…
P3068 [USACO13JAN]派对邀请函Party Invitations 题目描述 Farmer John is throwing a party and wants to invite some of his cows to show them how much he cares about his herd. However, he also wants to invite the smallest possible number of cows, remembering all t…
传送门 记录每一个编号在那些组中,可以用vector,这里选择链式前向星. 每一组用set 将被邀请的放到queue中 #include <set> #include <queue> #include <cstdio> #include <cstring> #include <iostream> #define N 1000001 using namespace std; int n, g, cnt, ans; int head[N], to[N…
题目:洛谷P3697 题目大意是有各站停列车(慢车,相邻2站时间A)和特急列车(相邻2站时间B),特急列车在特定站点停靠. 现在加一种快速列车(相邻2站时间C,A>C>B),停靠K站(包括所有特急列车停靠的站点),要求你设计快速列车的停靠站点,好让1号站点的人T分钟能到达的站点数尽可能多.(相邻指编号相邻的两站,如2号站和3号站) 具体见原题目. 我们设特急列车本次停靠点A,和下次停靠点B,再设从A坐慢车最远到达C,可知A到C之间不需要设任何快速站点. 那么就需要在C的后一个站D设快速站点.…
OJ题号:洛谷P3697 思路: 贪心.首先从起点出发,开特急电车,对于每一个特急车站$s_{i}$,分别下一次车,计算从当前车站$s_{i}$出发坐各停电车在指定时限内$t$最远能够到达的车站$r_{i}$,并保证这个$r_{i}$不会超过$s_{i+1}$.将得到的站点$r_{i}$放入一个大根堆中,堆中的每个元素记录两个值,第一个用来保存如果在当前站点开通快速电车,从当前站点坐快速电车总共能到达的站的个数:第二个用来保存当前站的编号$r_i$.最后不断地从堆中挑选最优的站,重复拓展到新的站…
题目描述 One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roads connects pairs of farms; road i requires…
P3071 [USACO13JAN]座位Seating 题目描述 To earn some extra money, the cows have opened a restaurant in their barn specializing in milkshakes. The restaurant has N seats (1 <= N <= 500,000) in a row. Initially, they are all empty. Throughout the day, there…
P2202 [USACO13JAN]方块重叠Square Overlap 题目描述 Farmer John is planning to build N (2 <= N <= 50,000) square fenced-in pastures on his farm, each of size exactly K x K (1 <= K <= 1,000,000). Pasture i is centered at point (x_i, y_i) with integer coo…
P3070 [USACO13JAN]岛游记Island Travels 题目描述 Farmer John has taken the cows to a vacation out on the ocean! The cows are living on N (1 <= N <= 15) islands, which are located on an R x C grid (1 <= R, C <= 50). An island is a maximal connected gro…
P3071 [USACO13JAN]座位Seating 题目链接 思路: 一开始把题给读错了浪费了好多时间呜呜呜. 因为第二个撤离操作是区间修改,所以我们可以想到用线段树来做.对于第一个操作,我们只需要维护suml,sumr,sum分别表示当前结点左端连续有多少个空位.右端连续有多少个空位.以及最长连续空位为多少就行了.因为每次安排作为可能会跨过mid,所以我们还需要数组来维护一下信息. 注意一下代码的细节吧: #include <bits/stdc++.h> using namespace…