随笔分类 -  并查集+图+线段树

摘要:欧拉筛法 1 vector<int> Prime(int n){ // 求解n以内(含n)的素数 2 bool flag[n + 1]; // 标记数组,flag[i]==0表示i为素数,flag[i]==1表示i为合数 3 memset(flag, 0, sizeof(flag)); 4 vect 阅读全文
posted @ 2022-09-03 19:17 剩下的交给时间就好 阅读(24) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/shifting-letters-ii/ 1 class Solution { 2 public: 3 string shiftingLetters(string s, vector<vector<int>>& shifts) { 4 int 阅读全文
posted @ 2022-09-03 19:09 剩下的交给时间就好 阅读(27) 评论(0) 推荐(0)
摘要:https://leetcode.cn/problems/shu-zu-zhong-de-ni-xu-dui-lcof/ 逆序对 区间更新+lazy标记 单点更新+无lazy标记 https://www.luogu.com.cn/problem/P3372 区间更新+lazy标记 离散化核心 用有序 阅读全文
posted @ 2022-08-20 17:37 剩下的交给时间就好 阅读(20) 评论(0) 推荐(0)
摘要:547. 省份数量 - 力扣(LeetCode) (leetcode-cn.com) 1 class Solution { 2 public: 3 vector<int>father; 4 int find(int x){ 5 if(father[x]==x) 6 return x; 7 retur 阅读全文
posted @ 2022-04-25 10:19 剩下的交给时间就好 阅读(34) 评论(0) 推荐(0)
摘要:题目链接 https://leetcode-cn.com/problems/longest-palindromic-substring/ 超时三次,最终选择看题解。 首先感觉是判断是否是回文这里出了问题,不应该傻傻for循环,要利用子结构。。。。嗐,学了个假dp 这个是改了题解,顺应自己思路的ac代 阅读全文
posted @ 2020-11-21 14:36 剩下的交给时间就好 阅读(65) 评论(0) 推荐(0)
摘要:1 #include <iostream> 2 #include <cstdio> 3 #include <memory.h> 4 using namespace std; 5 const int INF=0x3f3f3f3f,city=4; 6 int main(){ 7 int a[city][ 阅读全文
posted @ 2020-11-14 19:52 剩下的交给时间就好 阅读(101) 评论(0) 推荐(0)
摘要:带通配符的字符串匹配 http://noi.openjudge.cn/ch0206/6252/ #include <bits/stdc++.h> using namespace std; int main(){ bool dp[30][30]={0}; dp[0][0]=1; string x,y, 阅读全文
posted @ 2020-11-05 20:50 剩下的交给时间就好 阅读(91) 评论(0) 推荐(0)
摘要:P4779 【模板】单源最短路径(标准版) - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) dij 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int macn=1e5+50; 4 const int macm 阅读全文
posted @ 2020-11-03 13:50 剩下的交给时间就好 阅读(82) 评论(0) 推荐(0)
摘要:1 #include <iostream>//abcdab bcdb 2 #include <bits/stdc++.h> 3 using namespace std; 4 int main(){ 5 char x[105],y[105]; 6 cin>>x>>y; 7 int n,m; 8 n=s 阅读全文
posted @ 2020-11-03 13:14 剩下的交给时间就好 阅读(65) 评论(0) 推荐(0)
摘要:#include <iostream> #include <cstdio> #include <algorithm> #include <math.h>// 3 1 1 5 5 4 4 using namespace std; double d=1e9; struct node{ int x,y; 阅读全文
posted @ 2020-10-21 20:35 剩下的交给时间就好 阅读(79) 评论(0) 推荐(0)