随笔 - 530
文章 - 0
评论 - 3
阅读 -
10098
随笔分类 - 杂题
redis lru ,lfu
摘要:LRU 和 LFU 的区别 LRU 淘汰最近访问的数据中,时间最久远的 LFU 关注的是访问的频率,淘汰的是访问次数最少的数据。
阅读全文
缓存穿透,缓存击穿,缓存雪崩
摘要:缓存穿透:db 和 Redis 都没有需要的 key 1. 缓存空值 2.布隆过滤器 缓存雪崩:大量缓存失效 1. 互斥锁,并设置过期时间 2.redis集群,读写分离架构 缓存击穿:热点key失效 热点数据设置长 TTL
阅读全文
consul本地kv数据持久化
摘要:在macOS上(linux同理),如果你希望Consul在重启后能够保留KV数据,可以通过以下步骤配置Consul使用持久化存储。 使用文件系统作为后端存储 你可以将Consul配置为使用本地文件系统来持久化KV数据。下面是具体的步骤: 1. 创建数据存储目录 首先,创建一个目录来存储Consul的
阅读全文
无向环套树找环
摘要:dfs #include <iostream> #include <vector> #include <queue> #include <stack> #include <map> #include <cstring> using namespace std ; const int N=5001;
阅读全文
AT_abc260_e
摘要:给出 n 对点 ai ,bi ,在[1,m] 之间取一段区间。 当每一对点都有一个点在这个区间内时,这个区间合法。 求出不同长度的合法区间分别有多少个。 枚举 l, 右边r有个最小值R(l), 而 (l, j) j>r 之后的点都是合法点, 后面就是区间加,用差分维护 考虑这个 R (l) , 可以
阅读全文
map的遍历
摘要:for( x: iter ) x为一个pair map<int,int> mp ; signed main(){ mp[3] =4 ; mp[33] =1; for(auto xx:mp) cout << xx.first<<' '<<xx.second <<endl; }
阅读全文
树上 Kth father
摘要:来源于 https://vjudge.net/problem/CodeForces-291E void init(int x,int fa){ val[x]=val[fa]*S+(ul)c[x]; f[x][0]= fa; for (int i=1;i<20;++i) f[x][i]=f[f[x][
阅读全文
哈希表
摘要:要求O(1) 查找元素的存在 struct HashMap{ static const int Hash=999917,maxn=46340; int num,link[Hash],son[maxn+5],next[maxn+5],w[maxn+5]; int top,Stack[maxn+5];
阅读全文
常用头文件
摘要:#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<cmath> #include<algorithm> #include<stack> #include<queue> #include<ve
阅读全文
小a的学期
摘要:https://blog.csdn.net/u011815404/article/details/88381586 #include<iostream> #include<vector> #include <cstring> #include<string> using namespace std;
阅读全文
高精度板子
摘要:百度百科> #include<iostream> #include<vector> #include<string> using namespace std; struct wint:vector<int> { wint(int n=0) { push_back(n); check(); } win
阅读全文
Counting Rectangles UVA - 10574
摘要:给出n个点。问选出4个点作为定点,能够组成多少个平行与坐标轴的矩形。 点按照x排序 n^2挑选出 垂直x轴的线段,按照y1排序 #include<iostream> #include<cstring> #include<algorithm> #include<vector> using namesp
阅读全文
UVA1392 DNA Regions
摘要:https://www.luogu.com.cn/problem/UVA1392 给定两个长度为 n 的字符串 A 和 B,满足 A 和 B 都只由大写字母 A、C、G、T 组成。 求一个长度最长的闭区间 [L,R],满足对于 i∈[L,R] , 有不超过 p% 的 i 满足 Ai≠Bi
阅读全文
Unique Snowflakes uva11572
摘要:找最长的,没有相同元素的区间 双指针 #include <iostream> #include <set> using namespace std; const int N=1e6+2; int n,a[N]; void solve(){ int x=1,y=1,ans=0; set<int> st
阅读全文
Sumsets UVA - 10125
摘要:一个集合中需要找到 a,b,c,d ,使得 a+b+c=d 枚举a,b ,计算a+b,存在map里 再枚举d,c ,计算d-c 是否 存在 d-c==a+b #include <iostream> #include <map> #include <algorithm> #include <vecto
阅读全文
快读
摘要:inline int read(){ int s = 0, w = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') w = -1; for (; isdigit(c); c = getchar()) s
阅读全文
acwing 152. 城市游戏
摘要:#include "bits/stdc++.h" using namespace std; const int N=1e3+3; int n,m,a[N][N],s[N][N]; int A; int w[N],h[N],pp; void sov(int x){ int i,ans=0; pp=0;
阅读全文