装糊涂高手_
装糊涂高手_
全部文章
分类
算法入门基础(7)
题解(28)
归档
标签
去牛客网
登录
/
注册
装糊涂高手_的博客
不懂嵌入式的伪OIer
TA的专栏
4篇文章
0人订阅
算法入门基础
4篇文章
0人学习
题解 | #[NOIP2006]明明的随机数#
题解 | #铺地毯#
全部文章
(共36篇)
题解 | #字符框#
思路 遍历字符数组,考虑以当前遍历字符为左上元素的2*2矩阵是否符合规则即可 #include <bits/stdc++.h> using namespace std; int n,m,cot,res = 0; char car[52][52]; bool jgface(int x,i...
2023-01-03
0
397
题解 | #挖沟#
最小生成树板子题 直接上kruskal即可 #include <bits/stdc++.h> using namespace std; int n,m,cnt = 0; struct gra{ int x,y,edge; }G[500005]; int fa[100005]; ...
C++
最小生成树
2022-04-08
0
375
题解 | #公交线路#
最短路模板题 坑点:题目可能会给你重边,只要选最小的一条即可 1、dij算法 #include <bits/stdc++.h> using namespace std; int n,m,s,t; int dis[1010]; bool vis[1010]; int G[1010][101...
C++
最短路
2022-04-08
2
566
题解 | #食物链#
并查集 开个三倍的fa数组,分别代表三种逻辑方向即可 #include <bits/stdc++.h> using namespace std; const int Nmax = 1e5+5; int fa[3*Nmax]; int n,k; int find(int x){ r...
C++
并查集
2022-04-06
0
373
题解 | #DongDong认亲戚#
并查集模板题 #include <bits/stdc++.h> using namespace std; int fa[20020]; map<string,int> m1; int n,m; int find(int x){ return fa[x] == x ? ...
C++
并查集
2022-04-05
1
304
题解 | #[JSOI2007]建筑抢修#
思路:(可撤销贪心?)先按完成期限对建筑进行升序排序,优先选取完成期限较早的建筑,再用一个堆来维护每个建筑所需的完成时间,如果遍历到所需完成时间比堆顶小(因为此时完成期限为当前建筑中最大的值,此时pop掉堆顶的建筑可能可以让size更大(也就是最终答案))且新的所需时间加和不超过当前建筑完成期限的,...
C++
堆(优先队列)
2022-04-05
0
361
题解 | #Running Median#
考虑到在单调序列下中位数左边都是大于(小于)中位数的数,右边都是小于(大于)中位数的数,因此可构建两个堆来维护中位数的左右序列,同时维护两个堆的长度差的绝对值不大于1即可 #include <bits/stdc++.h> using namespace std; int p,m,tmp,...
C++
堆(优先队列)
2022-04-05
0
344
题解 | #Look Up#
思路:反向遍历Hi,用一个单调栈维护当前牛能仰望的最近的右对象的下标即可 #include <bits/stdc++.h> using namespace std; const int Nmax = 1e5+5; int n,H[Nmax],tmp[Nmax]; stack<in...
C++
单调栈
2022-04-05
1
324
题解 | #滑动窗口#
单调队列维护每个区间中有可能能成为最值的数即可 队列存元素下标(否则不知道怎么判断队内元素已经超出窗口了) #include <bits/stdc++.h> using namespace std; const int Nmax = 1e6+5; int n,k; int a[Nmax]...
C++
2022-04-04
0
269
题解 | #简单的数据结构#
考查STL的使用 直接使用deque,sort,reverse即可 #include <bits/stdc++.h> using namespace std; int T,n; deque<int> de; int main(){ std::ios::sync_wi...
队列
2022-04-04
0
354
首页
上一页
1
2
3
4
下一页
末页