2023年3月30日
摘要: 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 阅读(11) 评论(0) 推荐(0) 编辑
  2023年3月24日
摘要: https://www.acwing.com/problem/content/849/ 本题为经典的图形插入遍历题目 首先是手写链表 实现 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #i 阅读全文
posted @ 2023-03-24 09:40 ljq0120 阅读(7) 评论(0) 推荐(0) 编辑
  2023年3月20日
摘要: 图的建立有两种,邻接矩阵和邻接表。 邻接矩阵适用于图较为密集,(稀疏图太浪费存储空间了),图如果较为稀疏,则使用邻接表为宜,dijkstra算法就是以邻接表为基础的。 有向无权图 #include<iostream> #include <vector> #include <algorithm> #i 阅读全文
posted @ 2023-03-20 17:20 ljq0120 阅读(20) 评论(0) 推荐(0) 编辑
  2023年3月8日
摘要: /* ¸±²¢²é¼¯Ä£°å 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 阅读(11) 评论(0) 推荐(0) 编辑
  2023年2月21日
摘要: 一.堆的性质 1.堆是一颗完全二叉树 2.堆的顶端一定是“最大”,最小”的,但是要注意一个点,这里的大和小并不是传统意义下的大和小,它是相对于优先级而言的,当然你也可以把优先级定为传统意义下的大小,但一定要牢记这一点,初学者容易把堆的“大小”直接定义为传统意义下的大小,某些题就不是按数字的大小为优先 阅读全文
posted @ 2023-02-21 17:16 ljq0120 阅读(32) 评论(0) 推荐(0) 编辑
  2023年2月16日
摘要: 本篇为vector初学 头文件#include<vector> 1.首先创建vector vector<int> v; vector<double> v(10) //存储10个double 向量元素 2.尾部元素扩充 v.push_back(2) 3.1 下表方式访问 v[0]=2; 3.2 用迭代 阅读全文
posted @ 2023-02-16 17:39 ljq0120 阅读(11) 评论(0) 推荐(0) 编辑
  2023年2月15日
摘要: https://www.acwing.com/solution/content/24738/ 全称字符串前缀哈希法,把字符串变成一个p进制数字(哈希值),实现不同的字符串映射到不同的数字。对形如 X1X2X3⋯Xn−1XnX1X2X3⋯Xn−1Xn 的字符串,采用字符的ascii 码乘上 P 的次方 阅读全文
posted @ 2023-02-15 17:41 ljq0120 阅读(59) 评论(0) 推荐(0) 编辑
  2023年2月13日
摘要: 什么是前缀和 原数组: a[1], a[2], a[3], a[4], a[5], …, a[n]前缀和 Si为数组的前 i项和前缀和: S[i] = a[1] + a[2] + a[3] + … + a[i] 注意: 前缀和的下标一定要从 1开始, 避免进行下标的转换 #include "iost 阅读全文
posted @ 2023-02-13 17:28 ljq0120 阅读(14) 评论(0) 推荐(0) 编辑
  2022年11月16日
摘要: https://www.acwing.com/problem/content/828/ // // Created by Genes on 2020/12/12. // // 数组模拟单链表 #include<iostream> using namespace std; const int N = 阅读全文
posted @ 2022-11-16 17:34 ljq0120 阅读(11) 评论(0) 推荐(0) 编辑
  2022年10月4日
摘要: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 1000; char a[N],b[N]; int dp[N][N]; int main() { int lena,le 阅读全文
posted @ 2022-10-04 10:55 ljq0120 阅读(13) 评论(0) 推荐(0) 编辑