自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(51)
  • 收藏
  • 关注

转载 PyWiFi模块的应用与文档总结

文档部分常量网卡状态获取方式:Interface.Status()常量值:const.IFACE_DISCONNECTEDconst.IFACE_SCANNINGconst.IFACE_INACTIVEconst.IFACE_CONNECTINGconst.IFACE_CONNECTED从上到下依次从0到4编号,在python中表示为0-4的整数型身份验证算法co...

2019-03-24 21:56:00 414

转载 Tarjan思想求割点

一、算法描述  Tarjan算法求割点仍然用了tarjan思想中dfs求prenum的dfs序号,parent的dfs树,以及lowest这样一个记录最早回溯位置的数组。lowest计算时求下列情况的最小值,即:lowest[u]的值为:prenum[u];如果存在一条非树边(u,v),使得u与一个树上顶点连通,这种情况下的prenum[v];u的所有子节点的lowest  ...

2018-08-07 15:55:00 135

转载 计算几何-凸包-Graham算法

一、点集有序化-水平排序  在计算几何中,点集往往无序,因此在计算前需要对点集进行排序,使得算法可以有序高效运行。水平排序利用点在二维平面上固有的横纵坐标属性进行排序,只涉及点坐标的比较,与极坐标排序使用的三角函数相比没有精度问题。水平排序利用的规则为,纵坐标为第一关键字,横坐标为第二关键字,纵坐标升序排列,如果纵坐标相等,按横坐标升序排列。1 bool com(co...

2018-08-05 16:53:00 250

转载 网络流-推送-重贴标签算法

网络流的推送-重贴标签算法代码 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 struct pointtype{ 5 int e; 6 int h; 7 }point[1001]; 8 int map[1001][1001]...

2018-07-19 15:21:00 721

转载 网络流-Edmonds-Karp算法

网络流的Edmonds-Karp算法代码 1 #include<iostream> 2 #include<algorithm> 3 #include<list> 4 #include<queue> 5 #include<climits> 6 using namespace std; 7 int n...

2018-07-19 14:49:00 95

转载 网络流-Ford-Fulkerson算法

网络流的Ford-Fulkerson算法代码 1 #include<iostream> 2 #include<climits> 3 #include<algorithm> 4 #include<list> 5 using namespace std; 6 int map[1001][1001];//残存网络 ...

2018-07-19 14:45:00 112

转载 矩阵乘法及矩阵链乘的快速幂优化

一、矩阵乘法 1 struct datatype 2 { 3 int a[2][2]; 4 }; 5 datatype multiple(datatype x,datatype y) 6 { 7 datatype res; 8 memset(res.a,0,sizeof(res.a)); 9 for(int i=0...

2017-09-08 20:00:00 119

转载 二分图

一、二分图判断struct pointtype{ vector<int> next; int color;}point[100001];int n,m;queue<int> q;void init(){ scanf("%d%d",&n,&m); for(int i=1;i...

2017-08-31 16:59:00 66

转载 树状数组

https://en.wikipedia.org/wiki/Fenwick_tree 1 int a[100001]; 2 int b[100001]; 3 int n,m; 4 int lowbit(int x) 5 { 6 return x&(-x); 7 } 8 void init() 9 {10 scanf("%...

2017-08-30 13:52:00 121

转载 线段树

1 struct pointtype 2 { 3 long long sum; 4 long long lazy; 5 }tree[500001]; 6 void push_up(int root) 7 { 8 tree[root].sum=tree[root*2].sum+tree[root*2+1].sum;...

2017-08-30 12:40:00 74

转载 拓扑排序

https://en.wikipedia.org/wiki/Topological_sorting 1 struct pointtype 2 { 3 vector<int> next; 4 int in; 5 }point[1000001]; 6 int n,m; 7 queue<int> q; 8 list&l...

2017-08-30 12:29:00 75

转载 tarjan算法

https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm 1 struct pointtype 2 { 3 vector<int> next; 4 int col; 5 int lowlink; 6 bool vi...

2017-08-29 16:35:00 68

转载 prim算法

https://en.wikipedia.org/wiki/Prim%27s_algorithm 1 int n,m; 2 struct edgetype 3 { 4 int from; 5 int to; 6 int len; 7 }; 8 struct pointtype 9 {10 vector<ed...

2017-08-29 16:02:00 107

转载 poj - 2976 题解

01分数规划 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 struct datatype 6 { 7 int a; 8 int b; 9 double c;...

2017-08-29 12:49:00 85

转载 kruskal算法

https://en.wikipedia.org/wiki/Kruskal%27s_algorithm 1 struct edgetype 2 { 3 int from; 4 int to; 5 int len; 6 }edge[100001]; 7 int n,m; 8 bool com(const edgetype&...

2017-08-28 11:02:00 76

转载 floyd算法

https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm 1 int map[101][101]; 2 int n,m; 3 void init() 4 { 5 scanf("%d%d",&n,&m); 6 for(int i=1;i<=n;i++) ...

2017-08-28 10:51:00 66

转载 SPFA算法

https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm算法过程简述:变量定义:点集point,邻接表类型pointtype,dis是点的最小估计距离,next是点的邻接信息,vis是点的队内标记。q为队列。初始化:读入图信息,创建邻接表,起点最小估计距离设定 1 struct edgetype 2 ...

2017-08-28 10:36:00 84

转载 Dijkstra算法

https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm算法过程简述:变量定义:一个点集point,pointtype邻接表类型,next保存相邻点编号,dis保存点到起点距离,vis标识访问标记。一个最小堆heap。用于快速求出当前可到达点里拥有最小估计距离的点。初始化:读入图,建立邻接表,建立一个空堆,并将起点距离设为0,加...

2017-08-28 09:39:00 87

转载 高精度运算

一、高精度加法  高精度加法是模拟竖式运算得来,总结如下:  1.对字符串进行预处理  2.两个数组对应位置分别相加  3.从低位到高位扫描一遍,超过进制的向上进位  4.如果最高位大于进制,则向上进位 1 string s1,s2; 2 int a[10001],b[10001],c[10001]={}; 3 int la,lb,lc; 4 vo...

2017-08-26 14:02:00 95

转载 hdu - 1231 题解

题意:最大连续子序列问题+输出答案所在的区间题解:最大连续子序列问题状态转移方程:f[i]=max(a[i],f[i-1]+a[i])   答案所在区间的话可以在递推求状态的时候,顺便记录一下当前位置所在的序列左端点是谁,最后扫描的时候记录下最优解的位置,然后这个位置就是右端点,记录过的数据就是左端点。 1 #include<iostream> 2 #in...

2017-08-25 15:57:00 64

转载 hdu - 1237 题解

题意:给出一个数字计算式,包含+,-,*,/四种符号,计算值题解:最大坑点:不能仅仅判断第一个是0就结束计算,有可能有:0 + 1这样的情况所以1.判断第一个是否是0,如果是,则判断下一个符号是否是'\n'2.读入数字和运算符,如果是*,/,取出栈顶元素直接计算完成后压栈,如果是-,将数字相反数压栈,如果是+,将数字压栈。3.计算栈内元素之和 1 #include...

2017-08-25 08:58:00 100

转载 hdu - 1022 题解

题意:火车站有一个铁轨,出口和入口是同一个。给定火车入站序列,问能否调成成出站序列,如果能,输出出站操作。题解:模拟栈即可,如果栈空,则从入站序列取出首元素压栈,如果栈顶元素与出站序列首元素不同,则从入站序列取出首元素压栈,如果栈顶元素与出站序列首元素相同,则出栈,更新出站序列首元素。如果入站序列已空,而还在尝试取出首元素压栈,则判定为不能调整。 1 #include<...

2017-08-24 16:00:00 98

转载 hdu - 1213 题解

题意:给定朋友关系,是朋友的坐一个桌子,问需要多少桌子题解:并查集处理后看有多少组即可。 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 using namespace std; 5 int father[1001]; 6 int getfa...

2017-08-24 15:30:00 107

转载 hdu - 1870 题解

题意:字母B被包含在第几层括号里?题解:遇到左括号就+1,右括号-1,遇到B输出值即可。 1 #include<iostream> 2 #include<cstdio> 3 #include<string> 4 using namespace std; 5 int main() 6 { 7 string s;...

2017-08-24 15:26:00 111

转载 codeforces - 448C 题解

题意:给定一个栅栏,每次涂一行或者一列,问最少几次能够涂完题解:分治算法+DP思想,每次的状态从竖着涂和横着涂中选择,同时向更高的部分递归计算。 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<climits> 5 ...

2017-08-23 15:21:00 422

转载 poj - 3070 题解

题意:斐波那契数列的矩阵链乘求法。题解:快速幂优化矩阵链乘解决。 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring> 5 using namespace std; 6 struct datat...

2017-08-22 15:00:00 95

转载 poj - 3641 题解

题意:检验一个数是否是质数,且满足ap = a (mod p)题解:快速幂,质数检验 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cmath> 5 using namespace std; 6 long lo...

2017-08-22 13:17:00 110

转载 codeforces - 148E 题解

题目大意:一个公主有一个摆满瓷器的架子,她生气的时候就要打碎m个瓷器。这个架子有n层,每层的瓷器每次只能从最左边拿或者从最右边拿,问打碎的瓷器的最大价值。题解:这是一个分组背包的DP,首先将每一层上拿出瓷器的方案作为一个物品,拿出瓷器的方案的代价是瓷器数量,价值是这一层上所有方案中最大的价值。首先为了计算方案的时候可以快速计算,我们在读入的时候就计算出前缀和sum,然后在计算方案...

2017-08-20 16:04:00 141

转载 codeforces - 544C 题解

题目大意:有n个程序员,第i个人一行代码的bug数为ai。公司要写m行代码,问代码中bug量不超过b的方案数对mod取余的结果。题解:把一个人写一行代码看作一个物品,这样就成了n类物品的完全背包问题,且有两个代价,一个是需要写的代码量m,一个是bug数b 1 #include<iostream> 2 #include<cstdio> 3 #in...

2017-08-18 15:08:00 136

转载 poj - 1231 题解

题目大意:在一个二维平面上放一些字母。每个字母数量相同,问能否画一些划分二维平面的直线,使得相同字符全部分布在一个区域,且该区域仅有这一种字符。题解:首先我们定义l,r,u,d四个数组,分别表示对某一个字符划分区域的左、右、上、下边界。然后分别对四个数组进行扩展:如果一个字符的左边界被包含在另一个字符的区域内,那么这个左边界就更新为包含区域的左边界,其他也相同。最后检查一遍两条坐标轴...

2017-08-18 10:14:00 89

转载 SGU101题解

欧拉路径的解法见我的另一篇文章:http://www.cnblogs.com/shao0099876/p/7366852.html算法细节如下:读入边的数据,用sticktype存储,用vis标记解决输出时候的重复问题对于每一条边看做无向边,对于每一个顶点,其相邻顶点用next数组标记,因为顶点数少,且出现重边情况,所以用计数方法存储,amount存储顶点的度,vis标记用于...

2017-08-16 08:27:00 141

转载 codeforces - 106C 题解

混合背包问题 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<memory.h> 5 using namespace std; 6 struct datatype 7 { 8 int a; 9 ...

2017-08-15 14:58:00 180

转载 poj - 3624 题解

裸01背包 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 int v[3405]; 6 int w[3405]; 7 int f[13000]; 8 int main() 9 {1...

2017-08-15 14:55:00 134

转载 poj - 2250 题解

题意:魔改版的LCS问题。序列是单词序列解法:原版LCS的序列元素是数字,想办法把数字替换成单词就解决了 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 #include<str...

2017-08-15 14:54:00 117

转载 poj - 1163 题解

数字三角形问题 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdio> 5 using namespace std; 6 int a[101][101]; 7 int f[101][101]; 8 ...

2017-08-15 14:42:00 91

转载 poj - 2533 题解

典型的LIS问题 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 int a[1001]; 6 int f[1001]; 7 int main() 8 { 9 int n;10...

2017-08-15 14:40:00 83

转载 poj-1308 / hoj - 2120 题解

题意:给定一些结点之间的有向边(父子关系),问是否是一棵树题解:1.首先判定是否是空树,这个地方是个坑,容易漏判。2.判定树的根节点数量。3.从根节点开始搜索(我用的DFS),对找到的点打访问标记,如果出现重复访问就不是树。4.枚举结点,如果有没有被访问到的的结点说明不是树数据范围没给,但是亲测n不大于10000 1 #include<iostream>...

2017-08-14 09:53:00 116

转载 hoj - 1448 题解

题意:三维迷宫,求逃出去的最短时间题解:用DFS最佳,注意vis存储最短距离 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<climits> 5 #include<cstring> 6 ...

2017-08-11 14:05:00 147

转载 codeforces - 377A 题解

题目大意:给定一个n*m区域,#为墙,“.”为空地,填充k片空地,同时使得剩下的空地继续保持连通题目解法:DFS遍历sum-k片空地(sum是空地总数),然后枚举一遍,没有被遍历过的空地全部填充 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #in...

2017-08-11 10:02:00 167

转载 gym - 100952E 题解

题目大意:给定一个n*m的矩阵,要求放入数字1-l,并且给定的数对不可以在前后左右相邻,问有多少种方案题目解法:类似八皇后的解法,直接DFS枚举放入就好 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring&...

2017-08-11 09:42:00 203

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除