装糊涂高手_
装糊涂高手_
全部文章
题解
算法入门基础(7)
归档
标签
去牛客网
登录
/
注册
装糊涂高手_的博客
不懂嵌入式的伪OIer
全部文章
/ 题解
(共28篇)
[NOIP2016]蚯蚓
思路 对于每条蚯蚓,用一个结构体pair<int,long long>维护它最近一次被切的时间点以及它的长度,同时使用三个队列分别维护原来的蚯蚓、px部分的蚯蚓以及x-px部分的蚯蚓,每次选最长蚯蚓时比较三个队列队头元素即可 Code #include <iostream> ...
贪心
队列
2024-02-16
0
231
题解 | #神仙打架#
思路 纵向遍历,记录最大值(即第一个第一名),再遍历一次找出并列第一即可 注:输入数据为数字字符,先转换成整数 #include <bits/stdc++.h> using namespace std; int ar[102][102]; int winner[102]; int ma...
2023-01-03
0
397
题解 | #字符框#
思路 遍历字符数组,考虑以当前遍历字符为左上元素的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
首页
上一页
1
2
3
下一页
末页