NC25136 [USACO 2006 Ope B]Cows on a Leash】的更多相关文章

NC25136 [USACO 2006 Ope B]Cows on a Leash 题目 题目描述 给定如图所示的若干个长条.你可以在某一行的任意两个数之间作一条竖线,从而把这个长条切开,并可能切开其他长条.问至少要切几刀才能把每一根长条都切开.样例如图需要切两刀. 注意:输入文件每行的第一个数表示开始的位置,而第二个数表示长度. 输入描述 Line \(1\) : A single integer, \(N\) (\(2 <= N <= 32000\)) Lines \(2 \cdots N…
USACO 2006 November Gold Corn Fields 题目描述: Farmer John has purchased a lush new rectangular pasture composed of M by N square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertil…
题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into account, he wants to plant enough grass in each of his fields not only for the cows situated initially in that field, but also for cows visiting from nearby…
/* ID: vincent63 LANG: C TASK: milk2 */ #include <stdio.h> #include<stdlib.h> #include<string.h> struct time{ int begin; int end; int len; }; void sort(struct time t[],int n){ int i,j; struct time temp; ;i<n;i++){ for(j=i;j<n;j++){…
后缀数组 o(︶︿︶)o 唉傻逼了一下,忘了把后缀数组的字典范围改回20001,直接21交了上去,白白RE了两发……sigh 既然要找出现了K次的子串嘛,那当然要用后缀数组了>_>(因为我太弱不会自动机&树) ok离散化后上后缀数组,求出height数组>_>然后用个……ST表= =?! O(n)地扫一遍所有的区间……看所有长度为k的里面最大的min(i,i+k-1)是多少(当然,k要减一,因为是K个子串的话对应的是K-1个串的LCP) 水题还RE了两发→_→真是难过 /*…
数位DP 同上一题Windy数 预处理求个组合数 然后同样的方法,这次是记录一下0和1的个数然后搞搞 Orz cxlove /************************************************************** Problem: 1662 User: Tunix Language: C++ Result: Accepted Time:0 ms Memory:1280 kb ******************************************…
POJ 3253 Fence Repair STL堆操作 我想说,STL里堆是我目前见到最蛋疼的操作. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cstdlib> #include <cmath> #include <utility> #include <vector> #inc…
终于自己独立做出来一道题QAQ然而本校数据实在太水不能确定我是不是写对了... 原题: Farmer John的N(1<=N<=1000)头奶牛分别居住在农场所拥有的B(1<=B<=20)个牛棚的某一个里.有些奶牛很喜欢她们当前住的牛棚,而另一些则讨厌再在它们现在所在的牛棚呆下去. FJ在忍受了若干次奶牛的抱怨后,决定为所有奶牛重新安排牛棚,使最不满的那头奶牛与最高兴的奶牛的心情差异最小,即使这会让所有奶牛都更加郁闷. 每头奶牛都把她对各个牛棚的好感度从高到低排序后告诉了FJ.当然…
milk2解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------------------------------------------------------------------------------------------[题目] N个农民,每个农民从L[i]到R[i]时间给奶牛挤奶.问最长的一直有人挤奶的时间,和最长的没有人挤奶的时间.[数据范围] 1<=N…
标记数组(哈希) 1e6的范围,开一个char数组全然能够,有人为1,无人为0,注意边界就可以.最后线性扫描就可以. 时间复杂度,应该是O(n),n为最后结束的时间. 缺点就是--比較慢 /* ID:twd30651 PROG:milk2 LANG:C++ */ #include<iostream> #include<fstream> #include<string.h> #include<stdlib.h> char a[1000001]; using n…
[题目链接] 点击打开链接 [算法] 状压DP [代码] #include<bits/stdc++.h> using namespace std; #define MAXN 12 #define MOD 100000000 int M,N,i,j,k,ans,state; ][(<<)+],f[MAXN+][(<<)+],cnt[MAXN+],mat[MAXN+][MAXN+]; template <typename T> inline void read(…
直接模拟2333 #include<cstdio> #include<algorithm> using namespace std; int n,ans; void read(int &k){ k=; ; char c=getchar(); ),c=getchar(); +c-',c=getchar(); k*=f; } int main(){ read(n); ){ ) n=n*+; ; ans++; } printf("%d",ans); }…
倒过来的合并果子? 做法与合并果子一样 维护一个小根堆,每次取出最小的两个数进行合并 #include<cstdio> #include<algorithm> #include<queue> using namespace std; int n; ; struct cmp{ bool operator() (const int a,const int b)const{return a>b;} }; priority_queue<int,vector<i…
和上一题(POJ1743,上一篇博客)相似,只是二分的判断条件是:是否存在一段后缀的个数不小于k #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <map> using namesp…
题目大意: 输入N ( 1 ≤ N ≤ 20,000 ) :将一块木板分为n块 每次切割木板的开销为这块木板的长度,即将长度为21的木板分为13和8,则开销为21 接下来n行描述每块木板要求的长度Li ( 1 ≤ Li ≤ 50,000 ) 木板长度恰好等于各段木板长之和 Sample Input 3858 Sample Output 34 挑战上的一个奇妙的贪心的方法 #include <bits/stdc++.h> #define ll long long using namespace…
题目大意: 输入n m 接下来n行m列 0表示不能种玉米 1表示能 要求种玉米位置的上下左右四连通区域不能种玉米 输出方案数 Sample Input 2 31 1 10 1 0 Sample Output 9 Hint Number the squares as follows: 1 2 3  4 There are four ways to plant only on one squares (1, 2, 3, or 4), three ways to plant on two square…
题目描述 FJ发现他的牛经常跑到附近的草地去吃草,FJ准备给每个草地种足够的草供这个草地以及附近草地的奶牛来吃.FJ有N个草地(1<=N<=100000),有N-1条双向道路连接这些草地,FJ精心设计了这些道路使每两个草地有且仅有一条简单路径连接.第i个草场有Ci头牛,有时候奶牛会走过K条道路到其他草地吃草.FJ想知道每个草场最多可能有的奶牛数量Mi,即所有走过K条道路后可能到达i的奶牛总数. 输入格式 Line 1: Two space-separated integers, N and K…
codevs——1861 奶牛的数字游戏 2006年USACO  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 青铜 Bronze 题解       题目描述 Description 奶牛们又在玩一种无聊的数字游戏.输得很郁闷的贝茜想请你写个程序来帮她在开局时预测结果.在游戏的开始,每头牛都会得到一个数N(1<=N<=1,000,000).此时奶牛们的分数均为0.如果N是奇数,那么奶牛就会把它乘以3后再加1.如果N是偶数,那么这个数就会被除以2.数字每变动一次,这头奶牛…
Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given period time. The treats are interesting for…
Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6568   Accepted: 3459 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per da…
Corral the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1352   Accepted: 565 Description Farmer John wishes to build a corral for his cows. Being finicky beasts, they demand that the corral be square and that the corral contain a…
题目链接:http://poj.org/problem?id=3186 Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6548   Accepted: 3446 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amount…
Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…
Bad Hair Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17774   Accepted: 6000 Description Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants…
http://poj.org/problem?id=3254 Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9118   Accepted: 4843 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parc…
http://poj.org/problem?id=3190 Stall Reservations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3567   Accepted: 1276   Special Judge Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be m…
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares.…
在了解数位dp之前,先来看一个问题: 例1.求a~b中不包含49的数的个数. 0 < a.b < 2*10^9 注意到n的数据范围非常大,暴力求解是不可能的,考虑dp,如果直接记录下数字,数组会开不起,该怎么办呢?要用到数位dp. 数位dp一般应用于: 求出在给定区间[A,B]内,符合条件P(i)的数i的个数. 条件P(i)一般与数的大小无关,而与 数的组成 有关. 这样,我们就要考虑一些特殊的记录方法来做这道题.一般来说,要保存给定数的每个位置的数.然后要记录的状态为当前操作数的位数,剩下的…
Backward Digit Sums Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6350   Accepted: 3673 Description FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum ad…
http://poj.org/problem?id=3254 Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7588   Accepted: 4050 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parc…