随笔分类 -  其他 - 思维题

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 31 下一页
摘要:code: #include <cstdio> #include <cstring> #include <algorithm> #define N 100020 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using 阅读全文
posted @ 2019-12-23 18:49 EM-LGH 阅读(124) 评论(0) 推荐(0)
摘要:code: #include <cstdio> #include <algorithm> #define N 50020 #define ll long long #define setIO(s) freopen(s".in","r",stdin) using namespace std; stru 阅读全文
posted @ 2019-12-23 16:44 EM-LGH 阅读(130) 评论(0) 推荐(0)
摘要:你发现平均值不会很大,所以直接暴力枚举平均值,然后跑 4*100 次最小生成树取最小值即可. code: #include <cstdio> #include <cmath> #include <algorithm> #define N 2005 #define ll long long #defi 阅读全文
posted @ 2019-12-23 16:28 EM-LGH 阅读(154) 评论(0) 推荐(0)
摘要:非常好的一道思维题. code: #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #define lson x<<1 #define rson x<<1|1 #define N 500010 #d 阅读全文
posted @ 2019-12-23 15:43 EM-LGH 阅读(124) 评论(0) 推荐(0)
摘要:以前一直以为这道题很恶心,事实证明还好,好多地方脑残写丑了. code: #include <cstdio> #include <string> #include <cstring> #include <algorithm> #define N 50003 using namespace std; 阅读全文
posted @ 2019-12-21 16:00 EM-LGH 阅读(207) 评论(0) 推荐(0)
摘要:code: #include <string> #include <cstring> #include <cstdio> #include <algorithm> #define N 50003 #define lson now<<1 #define rson now<<1|1 #define in 阅读全文
posted @ 2019-12-21 09:33 EM-LGH 阅读(151) 评论(0) 推荐(0)
摘要:然而这只是 70pts 的部分分,考场上没想到满分怎么做(现在也不会) code: #include <cstdio> #include <string> #include <stack> #include <queue> #include <cstring> #include <algorithm 阅读全文
posted @ 2019-12-21 08:38 EM-LGH 阅读(199) 评论(0) 推荐(0)
摘要:求:$a^{bx \%p}\equiv 1(\mod p)$ 的一个可行的 $x$. 根据欧拉定理,我们知道 $a^{\phi(p)}\equiv 1(\mod p)$ 而在 $a^x\equiv 1(\mod p)$ 这个式子中 $x$ 是存在很多个解的. 这些解之间存在着循环节,使得任意解 $x 阅读全文
posted @ 2019-12-20 18:58 EM-LGH 阅读(266) 评论(0) 推荐(0)
摘要:题意:给定一颗树,有 $m$ 次操作. 操作 0 :向集合 $S$ 中加入一条路径 $(p,q)$,权值为 $v$ 操作 1 :给定一个点集 $T$,求 $T$ 的并集与 $S$ 中路径含交集的权和.(就是如果路径 $i$ 与 $T$ 有交集,就产生 $v_{i}$ 的贡献) 数据范围:路径长度 $ 阅读全文
posted @ 2019-12-20 17:56 EM-LGH 阅读(266) 评论(0) 推荐(0)
摘要:这个思路很巧妙啊 ~ code: #include <cstdio> #include <algorithm> #define N 2050 #define ll int #define setIO(s) freopen(s".in","r",stdin) using namespace std; 阅读全文
posted @ 2019-12-19 20:48 EM-LGH 阅读(159) 评论(0) 推荐(0)
摘要:好神啊 ~ 打表程序: #include <cstdio> #include <cstring> #include <algorithm> #define N 140000000 #define ll long long #define mod 998244353 #define setIO(s) 阅读全文
posted @ 2019-12-19 14:07 EM-LGH 阅读(136) 评论(0) 推荐(0)
摘要:判断有没有解:让所有没有障碍的格子都放一个士兵. 那么,题中要求最少放几个士兵,就是最多拿走几个士兵. 而由于行和列对士兵个数都是由要求的,这就规定了拿走的士兵的上界. 跑一个最大流来求就行了. code: #include <cstdio> #include <queue> #include <a 阅读全文
posted @ 2019-12-18 20:17 EM-LGH 阅读(169) 评论(0) 推荐(0)
摘要:Description 影魔,奈文摩尔,据说有着一个诗人的灵魂。事实上,他吞噬的诗人灵魂早已成千上万。千百年来,他收集了各式各样 的灵魂,包括诗人、牧师、帝王、乞丐、奴隶、罪人,当然,还有英雄。每一个灵魂,都有着自己的战斗力,而影魔,靠 这些战斗力提升自己的攻击。奈文摩尔有 n 个灵魂,他们在影魔宽 阅读全文
posted @ 2019-12-18 18:10 EM-LGH 阅读(188) 评论(0) 推荐(0)
摘要: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( 阅读全文
posted @ 2019-12-18 10:35 EM-LGH 阅读(187) 评论(0) 推荐(0)
摘要:问题转化为求每一个极长横线段与极长纵线段的交点个数. 这个东西用扫描线+树状数组维护一下就可以了. code: #include <cstdio> #include <algorithm> #define N 200005 #define setIO(s) freopen(s".in","r",st 阅读全文
posted @ 2019-12-18 09:17 EM-LGH 阅读(155) 评论(0) 推荐(0)
摘要:十分有趣的问题. 我们发现如果拿的话肯定要先拿一些大的. 所以我们可以先将所有数从小到大排序,令 $f[i]$ 表示拿完前 $i$ 小先手-后手的最大值. 则有转移:$f[i]=max(f[i-1],a[i]-f[i-1])$ 反复阅读:每次拿一些数字的贡献是这些数字中最小的值. 反复阅读上一句话, 阅读全文
posted @ 2019-12-17 20:50 EM-LGH 阅读(184) 评论(0) 推荐(0)
摘要:之前绝对做过几乎一模一样的题,现在做竟然忘了. code: #include <bits/stdc++.h> #define ll long long #define setIO(s) freopen(s".in","r",stdin) using namespace std; ll n,ans=1 阅读全文
posted @ 2019-12-17 20:08 EM-LGH 阅读(157) 评论(0) 推荐(0)
摘要:推到了一个推不下去的形式,然后就不会了 ~ 看题解后傻了:我推的是对的,推不下去是因为不需要再推了. 复杂度看似很大,但其实是均摊 $O(n)$ 的,看来分析复杂度也是一个能力啊 ~ code: #include <bits/stdc++.h> #define ll long long #defin 阅读全文
posted @ 2019-12-17 19:40 EM-LGH 阅读(140) 评论(0) 推荐(0)
摘要:看到这道题的第一个想法是二分+主席树(好暴力啊) 实际上不用这么麻烦,用一个双指针+桶扫一遍就行了 ~ code: #include <bits/stdc++.h> #define N 100006 #define setIO(s) freopen(s".in","r",stdin) using n 阅读全文
posted @ 2019-12-17 18:37 EM-LGH 阅读(181) 评论(0) 推荐(0)
摘要:不难发现,当我们要选的区间确定后,一定会把仓库安排到中间的稻草上(如果是偶数个的话中间两个都行)。 然后按照坐标从小到大枚举右指针,左指针一定不递减,双指针扫一下就行了. code: #include <bits/stdc++.h> #define N 100007 #define ll long 阅读全文
posted @ 2019-12-17 17:01 EM-LGH 阅读(153) 评论(0) 推荐(0)

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 31 下一页