![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
POJ
夕阳下的奔跑517
这个作者很懒,什么都没留下…
展开
-
【POJ】二分图的最大匹配
二分图:设G=(V,E)是一个无向图,看点集是否可以分为两个独立的点集。 一、染色法判定二分图 一个图是二分图:当且仅当图中不含奇数环。有奇数环一定不是二分图。 由于二分图中没有奇数环,所以染色过程(e.g.一个点染色为0,与这个点相连的点一定为1)中一定没有矛盾。 染色法: for(i=1;i<=n;i++) if(i未染色) dfs(i,1); 二、二分图的最大匹配 ...原创 2021-01-12 11:01:24 · 148 阅读 · 2 评论 -
【POJ】分治算法题目
3A:重要逆序对 http://algorithm.openjudge.cn/2020hw1/3A/ 题目:一个数列中,排在前面的数比排在后面的数大2倍,称为重要逆序对。计算数列中,重要逆序对的个数。 思路:使用分治算法的归并排序:将数列从中间一分为二,对左边排序;对右边排序;左右使用两个指针,将小的存入b数组 ...原创 2021-01-12 10:17:09 · 526 阅读 · 1 评论 -
【POJ】Dijkstra计算最短路
一、Dijkstra模板 https://www.acwing.com/problem/content/851/ 问题:计算1-n点到1点最短路径。 思路:循环n次:{1.找到dis最小值&没访问过的点 2.标记这个点已访问过 2.以这点更新其他所有点} 初始dis为无穷大,dis[1]=0;vis为false。 #include<iostream> #include<cstring> #include<algorithm> using namespace std原创 2021-01-10 14:18:05 · 198 阅读 · 1 评论 -
【POJ】DFS算法的应用
一、1E:Red and Black http://algorithm.openjudge.cn/2020hw1/1E/ 题目:根据图(邻接矩阵表示)进行深度优先遍历。 #include<iostream> #include<cstring> #include<queue> #include<vector> #include<functional> using namespace std; const int maxn = 25; char g[原创 2021-01-09 21:36:29 · 365 阅读 · 2 评论 -
【POJ】优先队列的应用
一、优先队列基本语法 1.定义 #include<queue> #include<functional> #include<vector> //大顶堆 priority_queue<int> maxheap; //小顶堆 priority_queue<int, vector<int>, greater<int>> minheap; 2.函数 maxheap.empty(); int t=maxheap.top(); max原创 2021-01-09 10:04:04 · 222 阅读 · 1 评论 -
【POJ】并查集算法题目
一、并查集算法模板 #include<iostream> #include<algorithm> #include<cmath> #include<cstring> using namespace std; const int maxn = 110;//点数最大值 int parent[maxn];//parent[i]=j——点i的父节点下标为j,初始均为-1(表示根节点) int rank_v[maxn];//自己根节点树的层数,初始为0 int un原创 2021-01-08 09:11:38 · 169 阅读 · 1 评论 -
【POJ】动态规划六题
一、背包问题 1、0-1背包 https://www.acwing.com/problem/content/2/ #include<iostream> #include<cmath> #include<algorithm> #include<cstring> #include<queue> using namespace std; const int maxn = 1010; int dp[maxn][maxn]; struct E{ int原创 2021-01-07 12:52:35 · 196 阅读 · 0 评论