![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Two Pointers
文章平均质量分 72
BraketBN
这个作者很懒,什么都没留下…
展开
-
【Codeforces650B】Image Preview【Two-Pointers】
懵逼,原来大暴力是可以过的。 显然访问过的照片都得看。 令x[i]为从1开始向右滑动到i的花费,y[i]为从1开始向左滑动到i的花费。 发现x[]和y[]都是单调的,所以可以Two-Pointers或者二分。 注意最后要和n取min。原创 2016-03-08 23:28:22 · 485 阅读 · 0 评论 -
【BZOJ3827】[Poi2014]Around the world【尺取法】【并查集】
【题目链接】 对于每个询问,设油量为d。 先预处理出每个点走一次最多走到哪,这个用尺取法可以O(n)。 然后得到一颗树,算一下每个点的深度。 枚举起点,在树上一直向上爬,直到距离超过n,爬的过程同时用并查集合并。 傻逼题卡内存。 /* Pigonometry */ #include #include #include using namespace std; cons原创 2016-04-14 22:56:30 · 905 阅读 · 0 评论 -
【BZOJ2348】[Baltic 2011]Plagiarism【二分】【或 Two Pointers】
【题目链接】 大水题竟然WA了2发。。 (1)二分找到位置后,贡献应该是id - l... (2)被卡精度了 /* Forgive me Not */ #include #include #include using namespace std; typedef long long LL; const int maxn = 100005; int n, num[max原创 2016-06-02 16:55:57 · 439 阅读 · 0 评论