03 2022 档案

摘要:选择排序 // // Created by 29273 on 2022-03-16. // #include "bits/stdc++.h" using namespace std; int n; int a[100]; void selectSort() { for (int i = 1; i < 阅读全文
posted @ 2022-03-16 16:12 沃特艾文儿 阅读(21) 评论(0) 推荐(0)
摘要:冒泡排序 // // Created by 29273 on 2022-03-16. // #include "bits/stdc++.h" using namespace std; int a[100]; int n; void bubbleSort() { int flag; for (int 阅读全文
posted @ 2022-03-16 15:54 沃特艾文儿 阅读(49) 评论(0) 推荐(0)
摘要:二分查找模板 // // Created by 29273 on 2022-03-16. // #include "bits/stdc++.h" using namespace std; int n,x; int a[100]; int binarySearch(int x) { int low = 阅读全文
posted @ 2022-03-16 15:29 沃特艾文儿 阅读(13) 评论(0) 推荐(0)
摘要:仅作记录,拓扑模板 // // Created by 29273 on 2022-03-16. // #include "bits/stdc++.h" using namespace std; const int maxN = 1e4 + 10; vector<int> V[maxN]; vecto 阅读全文
posted @ 2022-03-16 15:02 沃特艾文儿 阅读(29) 评论(0) 推荐(0)
摘要:最短路prim算法模板,仅作记录 // // Created by 29273 on 2022-02-23. // Prim 最短路径算法模板 #include<iostream> #include "bits/stdc++.h" using namespace std; const int max 阅读全文
posted @ 2022-03-16 11:09 沃特艾文儿 阅读(33) 评论(0) 推荐(0)
摘要:dijkstra 模板 需要对其进行改造 100 = value * 汇率 1 * 汇率2 * 。。。 那么汇率乘积越大越好 最短路便可改造为为最长路; dis 初始化为 0 d 数组初始化为 0(最短路均初始化为inf) 松弛条件判定改变 if (!vis[j] && dis[j] < dis[u 阅读全文
posted @ 2022-03-12 21:53 沃特艾文儿 阅读(17) 评论(0) 推荐(0)
摘要:对于已经连接的路距离设为零,断开的道路保持原先的距离跑一遍dijkstra 或者spfa 。 // // Created by 29273 on 2022-03-01. // #include "bits/stdc++.h" using namespace std; #define inf 0x3f 阅读全文
posted @ 2022-03-10 20:41 沃特艾文儿 阅读(22) 评论(0) 推荐(0)
摘要:简单dfs 对于每一个不为‘0’且未被访问的地方开始dfs搜索,将其连通不为‘0’的地方vis数组置为0(之后无需访问访问),ans++。 // // Created by 29273 on 2022-03-09. // #include "bits/stdc++.h" using namespac 阅读全文
posted @ 2022-03-10 15:58 沃特艾文儿 阅读(34) 评论(0) 推荐(0)
摘要:记录一下求解代码 思路 并查集作为工具,每次输入新的一组数据时将所有辅助空间重置menton数组,minX,maxX来记录输入数据的最大值,最小值以及输入过的数据,因为数据输入并不是从一开始也不是n-m连续的对于每一组数据 输入的每一对数据,先检验是否二者father是否相同,相同说明已经连通,再联 阅读全文
posted @ 2022-03-10 15:52 沃特艾文儿 阅读(35) 评论(0) 推荐(0)
摘要:原理不做赘述,仅当记录 #include<bits/stdc++.h> using namespace std; const int maxn = 1010; int g[maxn][maxn]; const int inf = 0x3f3f3f3f; void init(){ for(int i= 阅读全文
posted @ 2022-03-10 15:38 沃特艾文儿 阅读(23) 评论(0) 推荐(0)
摘要:树的直径 树上最远的两个节点之间的距离 dfs 两次dfs搜索 第一次 任一点开始进行搜索,找到距离最远点 第二次 从第一次最远点开始搜索再次搜索记录最远距离 // // Created by 29273 on 2022-03-07. // dfs 求树的直径 #include "bits/stdc 阅读全文
posted @ 2022-03-10 15:36 沃特艾文儿 阅读(28) 评论(0) 推荐(0)