随笔分类 - code
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1000; ll n, m, k, q, p;double sum, sum1, sum0; string s, r; int a[
阅读全文
摘要:bfs像二叉树的层序遍历 像这个图走bfs就{1, 2, 3, 4, 5, 6, 7, 8}这样走; dfs就{1, 2, 5, 6, 3, 7, 8, 4}。 bfs与queue相结合,走到哪就把哪加进queue,出时把最先进的那个点弹出,同时把弹出这个点有关连的点加入queue。 例:Luogu
阅读全文
摘要:Bellman Ford不常用下面有它的优化SPFA for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { d[v[i]] = min(d[v[i]], d[u[i]] + w[i]); } } Dijkstra d[s] = 0;/
阅读全文
摘要:预备知识:懒惰标志,就是在二叉树里,a有b c两个子儿子,现在要给b c各加1,先不直接加到b c上,把它俩要加的值先加到a上,待要实际用时a再把值传给他们。 线段树是算法竞赛中常用的用来维护 区间信息 的数据结构。 线段树可以在 O(log n) 的时间复杂度内实现单点修改、区间修改、区间查询(区
阅读全文
摘要:typedef struct HeapStruct *MaxHeap; struct HeapStruct{ int *Elements;/* 存储堆元素的数组 */ int Size;/* 堆的当前元素个数 */ int Capacity;/* 堆的最大容量 */ }; MaxHeap Creat
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int a[11][11]; bool visited[11]; void store_graph() { for(int i=1;i<=10;i++) for(int j=1;j<=10;j++) cin>>
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int a[11][11]; bool visited[11]; void store_graph(){//邻接矩阵存储图 int i,j; for(i = 1; i <= 10; i++) for(j = 1
阅读全文
摘要:#include<bits/stdc++.h> #define MaxVertexNum 100 /* 最大顶点数设为100 */ typedef int Vertex; /* 用顶点下标表示顶点,为整型 */ typedef int WeightType; /* 边的权值设为整型 */ typed
阅读全文
摘要:#include<bits/stdc++.h> #define MaxVertexNum 100 //最大顶点 #define INFINITY 65535 // ∞设为双字节无符号整数的最大值65535 using namespace std; typedef int Vertex; //用顶点下
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; //哈夫曼树结点结构 typedef struct { int weight;//结点权重 int parent, left, right;//父结点、左孩子、右孩子在数
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct AVLNode *Position; typedef Position AVLTree; struct AVLNode{ int data;
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct TreeNode {//定义二叉树结构 char Data; struct Node *lchild,*rchild; }*BiTree,B
阅读全文
摘要:typedef struct LNode *List; struct LNode{ int Data[MAXSIZE]; int Last;//最后一个,表长为last+1 }; struct LNode L; List PtrL; List MakeEmpty(){ List PtrL; PtrL
阅读全文
摘要:kmp,next带优化 #include<iostream> #include<bits/stdc++.h> using namespace std; void getnext(char p[],int next[]){ next[0]=-1; int i=0,j=-1; int n=strlen(
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct Node {//定义二叉树结构 char data; struct Node *lchild,*rchild; }*BiTree,BiTNo
阅读全文
摘要:#include <iostream> #include <cstdio> #include<bits/stdc++.h> using namespace std; //栈 typedef struct{ int *base; int *top; int stacksize; }sqstack; v
阅读全文
摘要:https://blog.csdn.net/Endeavor_G/article/details/80552680 https://blog.csdn.net/qq_39993896/article/category/7319745 这个详细 顺序表:https://blog.csdn.net/la
阅读全文
摘要:中文题意: 思路:我们先看看能不能直接从x翻到y,abs(y-x)%d==0,可以就直接输出abs(y-x)/d咯,不行的话之后有2种操作 1.先翻回到第一页,从第一页看看能不能范到y,不能的话翻到最后一页,倒回来翻看看能不能翻到y,不能的话这种方法不行; 2.翻到最后一页,倒回来看看能不能翻到y,
阅读全文
摘要:题意:求最长可以分a b a为三部分子串,a b a可以为空 思路在代码里 1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 #define ma
阅读全文
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1536 典型尼姆题,直接sg模板搞 之前mex设为int,怎么都TE过不了,看了讨论之后说设为bool就过了,但是我不知道为什么,是bool更快吗??? ac代码: 1 #include<cstdio> 2
阅读全文

浙公网安备 33010602011771号