随笔分类 - 算法
摘要:这个还是非常神仙的... code: #include <cstdio> #include <algorithm> #define N 1006 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using namespa
阅读全文
摘要:换根DP 求一下每个点为起点的最长路径,然后用双指针扫一下统计答案就好了. code: #include <cstdio> #include <queue> #include <set> #include <algorithm> #define N 1000007 #define ll long l
阅读全文
摘要:貌似是套路题. 假设给定我们一些区间,那么这些区间交集的左端点是左端点最靠右区间的左端点. 所以我们将所有区间按照左端点从小到大排序,然后用堆维护前 k 大的右端点. 那么,对于枚举到的第 $i$ 个区间来说,右端点就是第 $k$ 大的右端点与当前区间右端点的较小值. code: #include
阅读全文
摘要:推式子没推出来什么特别有用的结论. 看题解后发现这尼玛就是一个大爆搜啊. 以后碰到这种推式子推不出来,或者没啥思路的时候可以考虑爆搜解决. code: #include <cstdio> #include <string> #include <cstring> #include <algorithm
阅读全文
摘要:code: #include <cstdio> #include <cstring> #include <algorithm> #define N 100020 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using
阅读全文
摘要:code: #include <cstdio> #include <algorithm> #define N 50020 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using namespace std; stru
阅读全文
摘要:以前一直以为这道题很恶心,事实证明还好,好多地方脑残写丑了. code: #include <cstdio> #include <string> #include <cstring> #include <algorithm> #define N 50003 using namespace std;
阅读全文
摘要:这个思路很巧妙啊 ~ code: #include <cstdio> #include <algorithm> #define N 2050 #define ll int #define setIO(s) freopen(s".in","r",stdin) using namespace std;
阅读全文
摘要:好神啊 ~ 打表程序: #include <cstdio> #include <cstring> #include <algorithm> #define N 140000000 #define ll long long #define mod 998244353 #define setIO(s)
阅读全文
摘要:code: #include <bits/stdc++.h> #define N 100060 #define M 1000000 #define lson x<<1 #define rson x<<1|1 #define ll long long #define setIO(s) freopen(
阅读全文
摘要:看到这道题的第一个想法是二分+主席树(好暴力啊) 实际上不用这么麻烦,用一个双指针+桶扫一遍就行了 ~ code: #include <bits/stdc++.h> #define N 100006 #define setIO(s) freopen(s".in","r",stdin) using n
阅读全文
摘要:不难发现,当我们要选的区间确定后,一定会把仓库安排到中间的稻草上(如果是偶数个的话中间两个都行)。 然后按照坐标从小到大枚举右指针,左指针一定不递减,双指针扫一下就行了. code: #include <bits/stdc++.h> #define N 100007 #define ll long
阅读全文
摘要:比较神奇的贪心 有点类似于田忌赛马. 如果我方最弱强于对面最弱,则直接最弱pk最弱. 如果我方最强强于对面最强,那么直接最强间pk. 否则,试着用我方最弱 pk 对方最强,看是否能打成平手. code: #include <bits/stdc++.h> #define N 100006 #defin
阅读全文
摘要:做这道题真的是涨姿势了,一般的CDQ分治都是在序列上进行的,这次是把CDQ分治放树上跑了~ 考虑一半的 CDQ 分治怎么进行: 递归处理左区间,处理左区间对右区间的影响,然后再递归处理右区间. 所以,如果是有坐标不递增的斜率优化的话就用 CDQ 分治先处理出左半部分答案,然后将处理好的左区间答案用来
阅读全文
摘要:你发现只会改变一个位置,所以可以直接进行dp 具体转移的话用 CDQ 分治转移就好了~ #include <bits/stdc++.h> #define N 100006 #define setIO(s) freopen(s".in","r",stdin) using namespace std;
阅读全文
摘要:不是很难想,但是细节巨多 开始一个地方想错了,然后...... code: #include <bits/stdc++.h> #define N 2000006 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using
阅读全文
摘要:和超级钢琴,异或之三倍经验 $?$ 堆+贪心素质三连 $?$ 好无聊...... code: #include <bits/stdc++.h> #define N 500006 #define ll long long #define setIO(s) freopen(s".in","r",stdi
阅读全文
摘要:和超级钢琴几乎是同一道题吧... code: #include <bits/stdc++.h> #define N 200006 #define ll long long #define setIO(s) freopen(s".in","r",stdin) , freopen(s".out","w"
阅读全文
摘要:开始想到了一个二分+主席树的 $O(n\log^2 n)$ 的做法. 能过,但是太无脑了. 看了一下题解,有一个 ST 表+堆的优美解法. 你发现肯定是选取前 k 大最优. 然后第一次选的话直接选固定左端点,最优的右端点就行. 但是呢,这个右端点选完后就不能再选了,于是你把这个区间分成两个,再扔到堆
阅读全文
摘要:code: #include <bits/stdc++.h> #define N 100004 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using namespace std; ll S; ll val[N],d
阅读全文

浙公网安备 33010602011771号