acwing算法基础
wsfhdhjs
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
拓扑排序总结
有向图的拓扑排序 //因为我们最后要输出的是拓扑序列,所以bfs的时候用数组比较合适 //最后比较是tt==n-1,true为拓扑序列;false为不是 bool tuopu() { int hh=0,tt=-1; for(int i=1; i<=n; i++) if(!d[i]) q[++tt]=i; while(hh<=tt) { int t=q[hh++]; for(int i=h[t原创 2021-09-07 15:15:45 · 212 阅读 · 0 评论 -
第1讲 基础算法
快速排序 #include <iostream> using namespace std; const int N = 100010; int q[N]; void quick_sort(int q[], int l, int r) { if (l >= r) return; //这个表示 区间 只有 一个数了 就 不用 排序,直接退出就好 int i = l - 1, j = r + 1, x = q[l + r >> 1];原创 2021-05-18 18:58:53 · 171 阅读 · 0 评论 -
第二讲 数据结构
单链表 #include <iostream> using namespace std; const int N = 100010; // head 表示头结点的下标 // e[i] 表示节点i的值 // ne[i] 表示节点i的next指针是多少 // idx 存储当前已经用到了哪个点 int head, e[N], ne[N], idx; // 初始化 void init() { head = -1; idx = 0; } // 将x插到头结点 void原创 2021-05-09 21:11:57 · 406 阅读 · 1 评论 -
第3讲 搜索与图论
排列数字 #include <iostream> using namespace std; const int N = 10; int path[N]; bool st[N]; int n; // 计算u->n的所经过的路径path void dfs(int u) { // 边界条件 if (u == n) //这就是走到头了 { for (int i = 0; i < n; i++) printf("%d ", path[i]原创 2021-04-27 20:38:03 · 213 阅读 · 0 评论 -
第4讲 数学知识
试除法判定质数 #include<iostream> using namespace std; const int maxn=111; int n; bool isPrime(int x) { if(x<2) //注意x<2为return false return false; for(int i=2; i<=x/i; i++) //i<=x/i原创 2021-04-20 19:54:47 · 101 阅读 · 0 评论 -
第5将 动态规划
背包问题 01背包问题原创 2021-03-17 17:05:11 · 129 阅读 · 0 评论 -
第6讲
推公式 125 #include <iostream> #include <algorithm> using namespace std; /* 整个题的解题思路就是 ,按照w+s排好序,然后在计算出 最大值即可 */ typedef pair<int, int> PII; const int N = 50010; //1≤N≤50000, int n; PII cow[N]; int main() { scanf("%d", &原创 2021-03-15 16:09:44 · 223 阅读 · 0 评论
分享