Description It's a hot summer day, and Farmer John is letting Betsy go to the water park where she intends to ride every single slide. The water park has N (1 <= N <= 10,000) platforms (numbered 1..N) from which to enter the M (1 <= M <= 10,00…
题解: 很神奇的做法,把点分成入度大于出度和入度小于出度两种. 然后入度大于出度的点必须走到某个点,所以排序贪心. #include<stdio.h> #include<iostream> #include<algorithm> #include<stdlib.h> using namespace std; const int N=10005; int n,m,i,ans,x,y,k,s,a[N],p[N],b[N],c[N]; inline void re…
Water Slides 滑水 [问题描述] It's a hot summer day, and Farmer John is letting Betsy go to the water park where she intends to ride every single slide. The water park has N (1 <= N <= 10,000) platforms (numbered 1..N) from which to enter the M (1 <= M…
[BZOJ1659][Usaco2006 Mar]Lights Out 关灯 试题描述 奶牛们喜欢在黑暗中睡觉.每天晚上,他们的牲口棚有L(3<=L<=50)盏灯,他们想让亮着的灯尽可能的少.他们知道按钮开关的位置,但喜闻乐见的是他们并没有手指.你得到了一个长度为T(1<=T<=7)的插槽用以帮助奶牛们改变灯的状态. 输入 第一行,两个整数L和T.第二行给出一个长度为L的01串表示初始灯的状态,0表示灯是灭的,1表示灯是亮的.第三行给出一个长度为T的01串,表示你获得的插槽. 输出…
1657: [Usaco2006 Mar]Mooo 奶牛的歌声 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 631  Solved: 445[Submit][Status][Discuss] Description Farmer John's N (1 <= N <= 50,000) cows are standing in a very straight row and mooing. Each cow has a unique height…
1657: [Usaco2006 Mar]Mooo 奶牛的歌声 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 489  Solved: 338[Submit][Status] Description Farmer John's N (1 <= N <= 50,000) cows are standing in a very straight row and mooing. Each cow has a unique height h in the…
1657: [Usaco2006 Mar]Mooo 奶牛的歌声 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 526  Solved: 365[Submit][Status] Description Farmer John's N (1 <= N <= 50,000) cows are standing in a very straight row and mooing. Each cow has a unique height h in the…
题目链接 bzoj1722: [Usaco2006 Mar] Milk Team Select 产奶比赛 题解 dp[i][j][0 / 1] 以i为根的子数中 相邻点对选了j个的最大价值 代码 #include<vector> #include<cstdio> #include<cstring> #include<algorithm> #define gc getchar() #define pc putchar inline int read() { i…
1722: [Usaco2006 Mar] Milk Team Select 产奶比赛 https://www.lydsy.com/JudgeOnline/problem.php?id=1722 分析: f[u][i][0/1]表示子树u中,有i对相邻的点,最大和是多少. 代码: #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<iostrea…
1657: [Usaco2006 Mar]Mooo 奶牛的歌声 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 961  Solved: 679[Submit][Status][Discuss] Description Farmer John's N (1 <= N <= 50,000) cows are standing in a very straight row and mooing. Each cow has a unique height…
[USACO2006 Mar] 滑雪缆车 skilift Time Limit 1000 msMemory Limit 131072 KBytes Description 科罗拉多州的罗恩打算为奶牛建造一个滑雪场,为此要在山上规划一条缆车线路. 整座山可以用一条折线来描述,该折线有N个拐点,起点是1,终点是N.每个拐点的高度为Hi,相邻两个拐点之间的水平距离都是1. 缆车线路必须从起点开始修建,结束于终点.中间可以选择一些拐点安放缆绳的支柱,安全标准有两点:第一,缆绳的跨度有限制——相邻支柱的水…
直接树形dp就好了恩 令$f[i][j][t]$表示以$i$为根的子树,选出来的点存在$j$对父子关系,$t$表示$i$这个点选或者没选,的最大产奶值 分类讨论自己和儿子分别有没有选,然后转移一下就好了...恩,详情看代码好了 /************************************************************** Problem: 1722 User: rausen Language: C++ Result: Accepted Time:28 ms Mem…
Description 奶牛们喜欢在黑暗中睡觉.每天晚上,他们的牲口棚有L(3<=L<=50)盏灯,他们想让亮着的灯尽可能的少.他们知道按钮开关的位置,但喜闻乐见的是他们并没有手指.你得到了一个长度为T(1<=T<=7)的插槽用以帮助奶牛们改变灯的状态.   Input 第一行,两个整数L和T.第二行给出一个长度为L的01串表示初始灯的状态,0表示灯是灭的,1表示灯是亮的.第三行给出一个长度为T的01串,表示你获得的插槽. Output 第一行输出一个整数K,表示在满足亮着的灯最少…
题面戳我 题面描述 受到秘鲁的马丘比丘的新式水上乐园的启发,Farmer John决定也为奶牛们建一个水上乐园.当然,它最大的亮点就是新奇巨大的水上冲浪. 超级轨道包含 E (1 <= E <=150,000)条小轨道连接着V (V <= 50,000)个水池,编号为1..V.每个小轨道必须按照特定的方向运行,不能够反向运行.奶牛们从1号水池出发,经过若干条小轨道,最终到达V号水池.每个水池(除了V号和1号之外,都有至少一条小轨道进来和一条小轨道出去,并且,一头奶牛从任何一个水池到达V号…
Description Farmer John's N (1 <= N <= 50,000) cows are standing in a very straight row and mooing. Each cow has a unique height h in the range 1..2,000,000,000 nanometers (FJ really is a stickler for precision). Each cow moos at some volume v in th…
题目描述 受到秘鲁的马丘比丘的新式水上乐园的启发,Farmer John决定也为奶牛们建 一个水上乐园.当然,它最大的亮点就是新奇巨大的水上冲浪.超级轨道包含 E (1 <= E <=150,000)条小轨道连接着V (V <= 50,000)个水池,编号为1..V.每个小轨道必须按照特定的方向运行,不能够反向运行.奶牛们从1号水池出发,经过若干条小轨道,最终到达V号水池.每个水池(除了V号和1号之外,都有至少一条小轨道进来和一条小轨道出去,并且,一头奶牛从任何一个水池到达V 号水池.最…
http://www.lydsy.com/JudgeOnline/problem.php?id=1657 这一题一开始我想到了nlog^2n的做法...显然可做,但是麻烦.(就是二分+rmq) 然后我仔细的想了想,恩,对,单调栈可以完成...他们有传递性的.. 然后你懂的.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostrea…
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…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1657 题意: Farmer John的N(1<=N<=50,000)头奶牛整齐地站成一列“嚎叫”. 每头奶牛有一个确定的高度h(1<=h<=2000000000),叫的音量为v (1<=v<=10000). 每头奶牛的叫声向两端传播,但在每个方向都只会被身高严格大于它的最近的一头奶牛听到,所以每个叫声都只会被0,1,2头奶牛听到(这取决于它的两边有没有比它高的奶…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1657 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int n,h[N],c[N],q[N],he,tl,cnt[N],ans; int rdn() { ;;char ch=getchar(); ;ch=g…
Description Farmer John's N (1 <= N <= 50,000) cows are standing in a very straight row and mooing. Each cow has a unique height h in the range 1..2,000,000,000 nanometers (FJ really is a stickler for precision). Each cow moos at some volume v in th…
先考虑只能往一边传播,最后正反两边就行 一向右传播为例,一头牛能听到的嚎叫是他左边的牛中与高度严格小于他并且和他之间没有更高的牛,用单调递减的栈维护即可 #include<iostream> #include<cstdio> using namespace std; const int N=50005; int n,a[N],v[N],p[N],q[N],s[N],top,ans; int read() { int r=0,f=1; char p=getchar(); while(…
可以出模拟赛T1? #include <bits/stdc++.h> #define N 5002 #define inf 1000000 #define setIO(s) freopen(s".in","r",stdin) using namespace std; int f[N],h[N]; double slope(int i,int j) { double dx=(double)i-j; double dy=(double)(h[i]-h[j])…
Milk Team Select 产奶比赛 Description Farmer John's N (\(1 \le N \le 500\)) cows are trying to select the milking team for the world-famous Multistate Milking Match-up (MMM) competition. As you probably know, any team that produces at least X (\(1 \le X…
一.什么是贪心 贪心算法嘛... 就是在对某个问题求解时,总是做出在当前看来是最好的选择 In other wors,并不是从整体最优上加以考虑,而是在获得某种意义上的局部最优解 二.贪心算法的适用前提 局部的最优解能导致最后整体的最优解,即局部的最优解不受该部分以外的东西的影响 对于贪心算法,我们需要证明:整个问题的最优解一定由在贪心策略中存在的子问题的最优解得来的 实际上,能用贪心算法的问题很少,大部分看上去能用贪心算法去做的题目,其实都得不到最优解T T(这时候就需要运用动态规划了) 而看…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
大神们都在刷usaco,我也来水一水 1606: [Usaco2008 Dec]Hay For Sale 购买干草   裸背包 1607: [Usaco2008 Dec]Patting Heads 轻拍牛头 神转化,筛法 1609: [Usaco2008 Feb]Eating Together麻烦的聚餐  LIS 1610: [Usaco2008 Feb]Line连线游戏 排序 1611: [Usaco2008 Feb]Meteor Shower流星雨  BFS 1612: [Usaco2008…
soap webservice 调试工具: soap UI, 可以下载下来玩一玩. Introduction TLS, or transport layer security, and its predecessor SSL, which stands for secure sockets layer, are web protocols used to wrap normal traffic in a protected, encrypted wrapper. Using this techn…
续.....TAT这回不到50题编辑器就崩了.. 这里塞40道吧= = bzoj 1585: [Usaco2009 Mar]Earthquake Damage 2 地震伤害 比较经典的最小割?..然而一开始还是不会QAQ 和地震伤害1的区别在于这题求的是最少的损坏牧场数目.把牧场拆点,因为要让1和被报告的点不联通,把1归到S集,被报告的点归到T集,就变成求最小割了. 具体建图: 假设点拆成x和x’,x和x‘间连边(就是等下要割的).被报告的点和1点:容量无穷大(不能割):其他点容量为1. 原图中…
bzoj上的usaco题目还是很好的(我被虐的很惨. 有必要总结整理一下. 1592: [Usaco2008 Feb]Making the Grade 路面修整 一开始没有想到离散化.然后离散化之后就很好做了.F[I,j]表示第i个点,高度>=j或<=j,f[I,j]=min(f[i-1,j]+abs(b[j]-a[i]),f[I,j-1]) 1593: [Usaco2008 Feb]Hotel 旅馆 线段树 ★1594: [Usaco2008 Jan]猜数游戏 二分答案然后写线段树维护 15…