- 博客(11)
- 收藏
- 关注
原创 list + 并查集
https://ac.nowcoder.com/acm/contest/5668/G #include <iostream> #include <cstdio> #include <vector> #include <list> #include <cstring> using namespace std; int t, n, m; const int maxn = 8e5 + 10; vector <int> node[max
2020-07-19 19:10:54
143
原创 扩展欧几里得 + 线性筛质因数
https://ac.nowcoder.com/acm/contest/5668/F #include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define LL long long int t; LL a, b; LL prime[2000010] = {0}; bool isPrime[2000010] = {0}; LL pfactor[2000010
2020-07-19 15:19:40
166
原创 Coins POJ - 1742 优化的背包动态规划
明显的多重背包 若按普通写法的话复杂度Onmk一定超时 仔细想想 普通写法的话 dp[i][j]表示的是 前 i 件硬币 是否鞥凑成 j 的面值 即存的是1或0 这样会浪费好多信息 其实让dp[i][j][表示前i件硬币凑成j然后第i件硬币的剩余数 所以 当前i-1件硬币能够凑j时第i种硬币直接不用全剩下 即dp[i][j] = coinNum[i]; 否则当满足条件时dp[i][j] = dp[...
2020-04-18 10:33:12
169
原创 【模板】单调队列
单调队列 详细介绍添加链接描述 其实就是维护一个严格单调的队列(或栈) 保证这个队列是单调的且队列中的元素的顺序和和之前的前后顺序保持一致 维护的时候: 如果新的元素比队尾的元素小(假如是单调增队列)那么一直pop,直到新的元素比队尾元素大(直接加入队尾)或者和队尾元素相等(不用操作,因为该元素已经在队列中了)。即让该队列不存在比新元素大的元素了。 题目链接https://vjudge.net/c...
2020-04-08 22:26:48
208
原创 简单的区间dp Div2 Mar/25/2020 E - Array Shrinking
题目链接 题解连接 #include <iostream> #include <cstdio> #include <cstring> using namespace std; int num[510] = {0}; int f[510][510] = {0}; int w[510][510] = {0}; int read() { int x = 0, ...
2020-03-25 10:34:22
138
原创 (快速幂求逆元得到组合数)Mar/24/2020 16:46UTC+8Div2 D - Count the Arrays
快速幂 + 逆元 + 组合数 题目链接 题解链接 快速幂求逆元 关键:求解 a / b (mod p) – a b 很大无法直接约分 利用x = a^{p-2} (mod p) [基于费马小定理] 使用前提使p必须为质数 否则 应该利用扩展欧几里得来求逆元。 #include <iostream> #include <cstdio> using namespace s...
2020-03-24 17:05:57
127
原创 1325D - Ehab the Xorcist div2 Mar/23/2020 10:19UTC+8关于异或
[添加链接描述]题解链接:(https://www.cnblogs.com/stelayuri/p/12495726.html) [添加链接描述]题目链接:(https://codeforces.com/contest/1325/problem/D) 关于异或: 输入 运算符 输入 结果 1 ⊕ 0 1 1 ⊕ 1 0 0 ⊕ 0 0 0 ⊕ 1 1 1.一串数的异...
2020-03-23 10:26:57
188
原创 2020.3.6 div2 B
https://codeforces.com/contest/1316/problem/B 简单的规律 + 字符串的赋值处理 普通遍历赋值超时!!! 得用字符串的 substr 提取子串直接赋值 和 reverse 翻转!! 所以下一次处理字符串的时候一定要注意!!! 一开始的超时代码 #include <iostream> #include <cstdio> using...
2020-03-05 14:24:09
133
原创 最小生成树(一):Kruskal算法
https://vjudge.net/problem/POJ-1258 算法思路: 将边按边权从小到大排序 然后遍历 判断现在的边的两个端点是否在同一个连通块里 如果在就没有必要加边 如果不在 就加上 再维护连通块 (用并查集维护连通块) 时间复杂度为:ElogE #include <iostream> #include <cstdio> #include <algo...
2020-03-04 10:25:47
162
原创 网络流二:最大流(高阶)Dinic算法(bfs + dfs)
//网络流最大流Dinic算法(高阶) //Ps 要求出最大流中每条边的流量,怎么办? //将原图备份,原图上的边的容量减去做完最大流的残余网络上的边的剩余容量,就是边的流量。 // -------- //在普通情况下, DINIC算法时间复杂度为O(V2E) //在二分图中, DINIC算法时间复杂度为O(√VE) //https://blog.youkuaiyun.com/A_Comme_Amour/...
2020-03-04 09:35:37
350
原创 网络流一:最大流EK算法(bfs)
//POJ 1273 //https://blog.youkuaiyun.com/A_Comme_Amour/article/details/79356220 //网络流最大流EK算法 // 时间复杂度上限为nm^2 #include <iostream> #include <cstdio> #include <queue> #include <cstring...
2020-03-04 09:33:44
323
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人