CodeForces 645C Enduring Exodus】的更多相关文章

题目链接: http://codeforces.com/contest/645/problem/C 题意: 给定01串,将k头牛和农夫放进, 0表示可以放进,1表示不可放进,求农夫距离其牛的最大距离的最小值. 分析: 第一遍读题没看清,直接写成dp...然后样例都不过,我开始怀疑人生怀疑自己..... 后来发现是要求中间的到两边的最大距离的最小值,而对于某个距离是否满足条件很好判断啊~~所以直接二分最大距离即可~ 代码: #include<iostream> #include<cstri…
题目链接 我们将所有为0的位置的下标存起来. 然后我们枚举左端点i, 那么i+k就是右端点. 然后我们三分John的位置, 找到下标为i时的最小值. 复杂度 $ O(nlogn) $ #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <m…
枚举,三分. 首先,这$n+1$个人一定是连续的放在一起的.可以枚举每一个起点$L$,然后就是在$[L,R]$中找到一个位置$p$,使得$p4最优,因为越往两边靠,距离就越大,在中间某位置取到最优解,所以三分一下就可以了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include…
C. Enduring Exodus time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other…
题目链接: C. Enduring Exodus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to…
C. Enduring Exodus 题目连接: http://www.codeforces.com/contest/655/problem/C Description In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he…
链接 大意: n个房间, 1为占用, 0为未占用, John要将k头奶牛和自己分进k+1个空房间, 求John距最远的奶牛距离的最小值 这种简单题卡了20min.... 显然对于固定的k+1个房间, 只需要John在最接近中央的房间即可, 枚举每k个房间, 找出最接近的就行了 这样复杂度是$O(nlogk)$ 还可以直接二分答案, 复杂度$O(nlogn)$ #include <iostream> #include <algorithm> #include <cstdio&g…
快乐二分 用前缀和随便搞一下 #include <cstdio> using namespace std; ; int p[N]; ; inline int msum(int a, int b) { ) a = ; return (b - a - sum[b] + sum[a]); } inline bool judge(int s) { ; i <= n; i++) { ) continue; , i - ) + msum(i, i + s) >= k) return true;…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…