bzoj1784: [Usaco2010 Jan]island】的更多相关文章

现在居然出现一道题只有\(pascal\)题解没有\(C++\)题解的情况,小蒟蒻要打破它. 思维题:分类讨论 回归正题,此题十分考验思维,首先我们要考虑如何把不会走的地方给填上,使最后只用求一遍这个图的周长即可.考虑目标点的几种情况: \(0.\)当前点周围有三个\(A\)或四个\(A\)时:这个点肯定不会走到,直接用\(A\)填上. \(1.\)当前点夹在两个点中间,无法判断这个点被填上后是否会让两边出现独立的\(x\),所以跳过该点,之后如果某一边被填满,会导致这个点被重新搜到,那时再考虑…
2021: [Usaco2010 Jan]Cheese Towers Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 184  Solved: 107[Submit][Status] Description Farmer John wants to save some blocks of his cows' delicious Wisconsin cheese varieties in his cellar for the coming winter.…
2020: [Usaco2010 Jan]Buying Feed, II Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 220  Solved: 162[Submit][Status] Description (buying.pas/buying.in/buying.out 128M 1S) Farmer John needs to travel to town to pick up K (1 <= K <= 100) pounds of feed…
1783: [Usaco2010 Jan]Taking Turns Description Farmer John has invented a new way of feeding his cows. He lays out N (1 <= N <= 700,000) hay bales conveniently numbered 1..N in a long line in the barn. Hay bale i has weight W_i (1 <= W_i <= 2,0…
BZOJ_3049_[Usaco2013 Jan]Island Travels _状压DP+BFS Description 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…
Description 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 group of squares on the grid tha…
题意: 一排数,两个人轮流取数,保证取的位置递增,每个人要使自己取的数的和尽量大,求两个人都在最优策略下取的和各是多少. 注:双方都知道对方也是按照最优策略取的... 傻逼推了半天dp......然后看kpm的代码里一个语句解决 KPM大概思路:倒着取,设当前两人最大和分别为A和B(A为先取的人)..如果B+W[i]>A就把A和B交换(先取的人可以按照更优的取法,后手无人权..)..让A取W[i] 接下来是蒟蒻的傻逼写法: f[0][i],f[1][i]分别表示第1个人和第2个人,在i~n中取了…
http://www.lydsy.com/JudgeOnline/problem.php?id=2021 噗,自己太弱想不到. 原来是2次背包. 由于只要有一个大于k的高度的,而且这个必须放在最顶,那么我们就可以枚举每一个比k大的放在最顶,其它的都放在下边即可. 还有,注意这是完全背包! #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <i…
http://www.lydsy.com/JudgeOnline/problem.php?id=2020 和背包差不多 同样滚动数组 f[j]表示当前位置j份食物的最小价值 f[j]=min(f[j-l]+l*c) 1<=l<=f 而且在每一步走的时候 f[j]+=j 然后就行了.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include &…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2020 题意: FJ开车去买K份食物. 如果他的车上有X份食物,每走一里就花费X元. FJ的城市是一条线,总共n里路,有n+1个地方,标号0~n. FJ从0开始走,到n结束(不能往回走),要买m份食物. 城里有t个商店,每个商店的位置是x[i](一个点上可能有多个商店),有f[i]份食物,每份c[i]元. 问到达n并买m份食物的最小花费. 题解: 贪心. 每一份食物实际的话费 = 它的价格…