CF1368E Ski Accidents】的更多相关文章

读懂题是第一要素. 考虑把点集分割为:\(A,B,C\) 首先把所有入度为\(0\)的点加入\(A\) 然后对所有入边只来自\(A\)的点加入\(B\) 然后对所有入边只来自\(B\)的点加入\(C\) 剩下的全部加入\(C\) 此时: A:只有入度为0的点,或者全部入边全来自C B:只有来自A的入度 C:至少有来自B的入度 那么这要我们删掉C,即可保证没有三点是联通的. 由于每个点只有两个出度,所以我们可以证明,\(|C| \leq \frac{4}{7}n\) #include<iostre…
题目链接:https://codeforces.com/contest/1368/problem/E 题意 给出一个 $n$ 点 $m$ 边的有向图,每条边由编号较小的点通向编号较大的点,每个点的出度不大于 $2$,删掉一些点,使得图中不存在长度大于等于 $2$ 的路径.(最多删掉 $\frac{4}{7}n$ 个点) 题解 删除所有拓扑排序中深度为 $3$ 的倍数的顶点,由于每次删掉了一层,所以把所有点深度置为 $1$,只删除深度为 $3$ 的顶点即可. 证明 删除点占比最大的情况是该有向图为…
Codeforces 题面传送门 & 洛谷题面传送门 神仙构造题(不过可能我构造太烂了?) 首先考虑这个奇奇怪怪的 \(\dfrac{4}{7}\),以及这个每个点出度最多为 \(2\) 的条件有何用意.容易发现 \(4=2^2,7=1+2+4\),这启发我们通过某种方式将原图的点集分成三部分.我们考虑构造三个点集 \(A,B,C\) 满足: 对于 \(A\) 中的点 \(x\),要么其入度为 \(0\),要么所有连向它的边的另一个端点都属于 \(C\) 对于 \(B\)​ 中的点 \(x\),…
Ski Course Design Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer elevation in the range 0 .. 100. In the winter, since there is abundant snow on these hills, FJ routinely operates a ski training camp. Unfortunately, FJ h…
                                    Cow Ski Area Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3323   Accepted: 919 Description Farmer John's cousin, Farmer Ron, who lives in the mountains of Colorado, has recently taught his cows to s…
Description Farmer John's cousin, Farmer Ron, who lives in the mountains of Colorado, has recently taught his cows to ski. Unfortunately, his cows are somewhat timid and are afraid to ski among crowds of people at the local resorts, so FR has decided…
Ski Course Design Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer elevation in the range 0 .. 100. In the winter, since there is abundant snow on these hills, FJ routinely operates a ski training camp. Unfortunately, FJ h…
滑雪(ski) 题目描述 Michael喜欢滑雪.这并不奇怪,因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道在一个区域中最长的滑坡.区域由一个二维数组给出.数组的每个数字代表点的高度. 输入 第1行为表示区域的二维数组的行数R和列数C(1≤R,C≤l00).下面是R行,每行有C个数,代表高度. 输出 输出区域中最长滑坡的长度. 样例输入 5 5 1 2 3 4 5 16 17 18 19 6 15 24…
题目描述 Farmer John wants to take Bessie skiing in Colorado. Sadly, Bessie is not really a very good skier. Bessie has learned that the ski resort is offering S (0 <= S <= 100) ski classes throughout the day. Lesson i starts at time M_i (1 <= M_i &l…
在进行了一次结对编程.一次团队编程和一次个人编程项目后,读了<No Silver Bullet: Essence and Accidents of Software Engineering>,在此说说自己的感想体会.在团队编程中我们遇到了很多个人.结对编程时没有遇到的问题. Of all the monsters that fill the nightmares of our folklore, none terrify more than werewolves, because they t…
Ski Course Design Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer elevation in the range 0 .. 100. In the winter, since there is abundant snow on these hills, FJ routinely operates a ski training camp. Unfortunately, FJ h…
In this lesson you will learn to talk about past occurences. 过去进行时 课上内容(Lesson) C: Hi, Loki! L: Hi, Corrine.Good evening! L: Long time no see. C: Yeah, How is evething? L: Oh, I had a holiday last week     # 这里的had 是have 的过去形式 C: How do you feel when…
嘟嘟嘟 先考虑这两点: 1.如果我们有结束时间相同的课程,且达到的能力相同,那么我们一定选择开始时间最晚的. 2.如果有能力值相同的滑雪坡,我们一定选择时间最短的. 因此先预处理两个数组.cla[i][j]代表在 i 时刻结束,能力值达到 j 的课程中开始的最晚时间,ski[i]代表需要能力值至少为 i 的滑雪坡中最短的时间. 令dp[i][j] 表示 在 i 时刻,能力值为 j 时最多的滑雪次数,g[j]表示在当选前的时刻 i 时能力值为 j 时最多的滑雪次数,则 g[j] = max(dp[…
Description Farmer Ron in Colorado is building a ski resort for his cows (though budget constraints dictate construction of just one ski lift). The lift will be constructed as a monorail and will connect a concrete support at the starting location to…
Description Farmer Ron in Colorado is building a ski resort for his cows (though budget constraints dictate construction of just one ski lift). The lift will be constructed as a monorail and will connect a concrete support at the starting location to…
John loves winter. Every skiing season he goes heli-skiing with his friends. To do so, they rent a helicopter that flies them directly to any mountain in the Alps. From there they follow the picturesque slopes through the untouched snow. Of course th…
题目链接:点击打开链接 题意: 给出n个点m条无向边的图 開始图里没有边.每次加一条边,然后输出图里欧拉回路的条数. 思路: We will count the number of ski bases including the base consisted of empty subset of edges (before printing just subtract one). In the beginning the number of bases is equal to 1. If we…
[USACO2009 Open]滑雪课程 Ski Lessons Time Limit: 1000 ms Memory Limit: 131072 KBytes Description 约翰请贝西去科罗拉多去滑雪.不过贝西不太会玩,她只是个滑雪能力为1的渣渣.所以她决心参加一些滑雪课程.滑雪场提供S门课程,第i门课开始的时间是Mi,持续时间为Li ,上完课之后,贝西的滑雪能力将变成Ai.注意,能力不是增加Ai,而是变成Ai. 滑雪场有N条斜坡,第i条斜坡滑行一次需要Di 分钟,要求游客的滑雪能力…
POJ 2375 Cow Ski Area id=2375" target="_blank" style="">题目链接 题意:给定一个滑雪场,每一个点能向周围4个点高度小于等于这个点的点滑,如今要建电缆,使得随意两点都有路径互相可达,问最少须要几条电缆 思路:强连通缩点.每一个点就是一个点.能走的建边.缩点后找入度出度为0的个数的最大值就是答案.注意一開始就强连通了答案应该是0 代码: #include <cstdio> #includ…
     本文翻译自维基百科词条:http://en.wikipedia.org/wiki/Ski_rental_problem 滑雪租赁问题(ski rental problem)是一类问题的总称,指在持续重复花费和消除或减少重复花费后一次性付清两种策略间做出选择.      问题阐述:      许多在线问题(online problems)有名为租/买问题的子问题.我们需要在保持现有每隔一段时间付一定费用,或利用若干次固定大规模付费一次付清两种情况下做出选择.滑雪租赁就是一个经典的小例子,…
Cow Ski Area Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 237564-bit integer IO format: %lld      Java class name: Main   Farmer John's cousin, Farmer Ron, who lives in the mountains of Colorado, has recen…
P3650 [USACO1.3]滑雪课程设计Ski Course Design 题目描述 农民约翰的农场里有N座山峰(1<=N<=1000),每座山都有一个在0到100之间的整数的海拔高度.在冬天,因为山上有丰富的积雪,约翰经常开办滑雪训练营. 不幸的是,约翰刚刚得知税法在滑雪训练营方面有新变化,明年开始实施.在仔细阅读法律后,他发现如果滑雪训练营的最高和最低的山峰海拔高度差大于17就要收税.因此,如果他改变山峰的高度(使最高与最低的山峰海拔高度差不超过17),约翰可以避免支付税收. 如果改变…
题目描述 The cross-country skiing course at the winter Moolympics is described by an M x N grid of elevations (1 <= M,N <= 500), each elevation being in the range 0 .. 1,000,000,000. Some of the cells in this grid are designated as starting points for t…
洛谷P2948 看到题目就觉得这是动规但一直没想到如何状态转移……看了别人的题解之后才有一些想法 f[i][j]:前i单位时间能力值为j可以滑的最多次数 lessons[i][j]:结束时间为i,获得能力为j的时长最短的课程的开始时间 ski[i]:能力值为i可以滑的时间最短的坡的时长 d[i]表示前i时长最多可以滑的坡数 几个状态转移方程: 喝可可:f[i][j]=max(f[i][j],f[i-1][j]) 滑雪:f[i][j]=max(f[i][j],f[i-ski[j]][j]+1) 上…
LGOJ3101 [USACO14JAN]滑雪等级Ski Course Rating [问题描述] The cross-country skiing course at the winter Moolympics is described by an M x N grid of elevations (1 <= M,N <= 500), each elevation being in the range 0 .. 1,000,000,000. Some of the cells in this…
n个点(n<=1000)大小范围[0,100],改变一些点的值,使得极差不超过17,代价为改变值的平方. 枚举修改后的最低高度low,维护最小代价. /* TASK: skidesign LANG:C++ URL:http://train.usaco.org/usacoprob2?a=LxVrSLLAzuR&S=skidesign */ #include <iostream> #include <algorithm> #include <cstdio> #…
http://poj.org/problem?id=2375 题意:一个500*500的矩形,每个格子都有一个高度,不能从高度低的格子滑到高度高的格子(但相等高度可以滑),已知可以在2个相邻格子上加桥,使得无视他们的高度就可以互相滑,问最少加多少桥可以使得在任一个格子上都能到达任一个格子. 分析:很容易看出这就是相当于在一个有向图上至少加多少边可以使得其强联通,ans=max(入度0的点数,出度为0的点数),很好理解,可以把出度为0的点挂一条边到入度为0的点上,多了的随便挂.那么现在面临的问题的…
DP. ; var t,s,n,i,j,m,l,a,c,d:longint; f,e:array[..,..maxn] of longint; q:array[..] of longint; g:array[..maxn] of longint; function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; begin readln(t,s,n); to s do begin readln(m,l,…
题目链接:http://poj.org/problem?id=2375题目大意:一片滑雪场,奶牛只能向相邻的并且不高于他当前高度的地方走.想加上缆车是的奶牛能从低的地方走向高的地方,求最少加的缆车数,是的奶牛可以从任意一个角落到达任意另外的角落解题思路:奶牛可以向相邻的不高于他的地方走,相当于u,v之前连通.若想加上缆车是图成为连通图,数目就是max(root, leave);思路同POJ 1236 代码如下: #include<stdio.h> #include<string.h>…
Description Farmer John 想要带着 Bessie 一起在科罗拉多州一起滑雪.很不幸,Bessie滑雪技术并不精湛. Bessie了解到,在滑雪场里,每天会提供S(0<=S<=100)门滑雪课.第i节课始于M_i(1<=M_i<=10000),上的时间为L_i(1<=L_i<=10000).上完第i节课后,Bessie的滑雪能力会变成A_i(1<=A_i<=100). 注意:这个能力是绝对的,不是能力的增长值. Bessie买了一张地图,…