03 2023 档案
848. 有向图的拓扑序列
摘要:https://www.acwing.com/problem/content/850/ #include<bits/stdc++.h> using namespace std; const int N=100010; vector<int> p[N]; //vector变长数组来写邻接表 queue 阅读全文
posted @ 2023-03-30 17:24 ljq0120 阅读(15) 评论(0) 推荐(0) 编辑
图中点的层次
摘要:https://www.acwing.com/problem/content/849/ 本题为经典的图形插入遍历题目 首先是手写链表 实现 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #i 阅读全文
posted @ 2023-03-24 09:39 ljq0120 阅读(18) 评论(0) 推荐(0) 编辑
邻接表 存储 vector
摘要:图的建立有两种,邻接矩阵和邻接表。 邻接矩阵适用于图较为密集,(稀疏图太浪费存储空间了),图如果较为稀疏,则使用邻接表为宜,dijkstra算法就是以邻接表为基础的。 有向无权图 #include<iostream> #include <vector> #include <algorithm> #i 阅读全文
posted @ 2023-03-20 17:20 ljq0120 阅读(37) 评论(0) 推荐(0) 编辑
并查集
摘要:/* ¸±²¢²é¼¯Ä£°å int find(int x) {//²éѯ²Ù×÷ if (x != fa[x]) fa[x] = find(fa[x]); return fa[x]; } void unionSet(int x, int y) {//ºÏ²¢²Ù×÷ x = find(x);/ 阅读全文
posted @ 2023-03-08 10:57 ljq0120 阅读(17) 评论(0) 推荐(0) 编辑