摘要: 仍然是拓扑排序,找最长路 #include<iostream> #include<vector> #include<queue> using namespace std; const int maxn=10001; int n,m,ans,t[maxn],tot[maxn],in[maxn]; ve 阅读全文
posted @ 2023-07-27 22:00 浪矢-CL 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 广搜入度为0 的点 #include<bits/stdc++.h> using namespace std; const int N=1e2+10; int in[N],n; vector<int>v[N]; queue<int>q; void topsort() {//拓扑排序 while(!q. 阅读全文
posted @ 2023-07-27 21:36 浪矢-CL 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 只要距离不是0x3f3f3 就代表能联通 #include <bits/stdc++.h> using namespace std;//防X抄袭 int n; int a[110][110]; #define inf 0x3f3f3f3f int main() { cin >> n; for (in 阅读全文
posted @ 2023-07-27 21:26 浪矢-CL 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 套模版,然后求和 #include<bits/stdc++.h> using namespace std; int n,m,ans=0; int dis[101][101],a[10001]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i+ 阅读全文
posted @ 2023-07-27 21:14 浪矢-CL 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 如题 可以理解为不断地消除中间节点k,把 i 和 j 经过中间节点的最短距离更新到 map[i][j]中, 相当于我们在i和j之间直接建立了一条可以用map[i][j]最短路径(把中间节点k消除了) 遍历n次就把所有的中间节点消除了,在任何两个节点 i,j 之间都建立了一条直连的最短路径map[i] 阅读全文
posted @ 2023-07-27 21:08 浪矢-CL 阅读(464) 评论(0) 推荐(1) 编辑
摘要: 广搜图的题 #include <iostream> #include <cstring> #include <vector> #include <queue> using namespace std; const int maxn = 1e6+5, maxm = 2e6+5; const int m 阅读全文
posted @ 2023-07-27 20:26 浪矢-CL 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 图论简介: 图(Graph) 图可以被表示为 G={V, E},其中 V={v1, ... , vN}表示n个点,E= {e1, ... , eM}表示m条边。 常用的储存方式包括邻接表和邻接矩阵。 连通分量(Connected Component):各节点间至少存在一条边可以连通。 图的最短路入门 阅读全文
posted @ 2023-07-27 20:12 浪矢-CL 阅读(12) 评论(0) 推荐(0) 编辑