sunny_forever
sunny_forever
全部文章
题解
归档
标签
去牛客网
登录
/
注册
梨小畅的空间
全部文章
/ 题解
(共57篇)
题解 | #小C的记事本#
Code #include <bits/stdc++.h> using namespace std; const int N = 1e6+10; string stk[N]; int hh; int main(){ int q; while(cin>>...
模拟栈
2021-08-05
2
603
题解 | #DongDong认亲戚#
并查集 + map Code #include <bits/stdc++.h> using namespace std; const int N = 20010; unordered_map<string,string>fa; int n,m; string find...
map
并查集
2021-08-05
5
430
题解 | #小A的柱状图#
思路 枚举每个矩形,求出该矩形向左右两侧延伸能得到的最大矩形面积:res_i答案就是 max(res_1,res_2,...,res_n) 代码中一些变量的解释:l[i]:矩形 i 的左边界:从 i 向左延伸,第一个比其高度小的矩形位置r[i]:同理 Code #include <bits/s...
单调栈
2021-08-05
1
317
题解 | #区区区间间间#
思路 问题可以转化为 求每个区间(区间长度大于1的区间)的最大值 与 最小值,最大值之和 减去 最小值之和 就是答案 注:下面所提区间,默认 区间长度大于 1 如何求 最大值之和 与 最小值之和 1:枚举每个区间,时间复杂度 O(n^2) ==> 超时 2:枚举每个值,假设该值为区间最大值...
单调栈
2021-08-05
7
680
题解 | #指纹锁#
看了大佬题解,学到了 Code #include <bits/stdc++.h> using namespace std; int m,k,x; char s[10]; struct cmp{ bool operator () (const int & x,con...
set
2021-08-04
1
527
题解 | #[NOIP2004]合并果子#
每次合并最轻的两堆 Code #include <bits/stdc++.h> using namespace std; const int N = 10010; typedef long long ll; priority_queue<int,vector<int&...
优先队列
2021-08-04
1
531
题解 | #好串#
转化为:括号匹配 Code #include <bits/stdc++.h> using namespace std; const int N = 100; char s[N]; int main(){ cin>>s+1; int d=0; bool ...
stack
2021-08-04
1
476
题解 | #新建 Microsoft Office Word 文档#
思路 优先队列 Code #include <bits/stdc++.h> using namespace std; const int N = 100010; priority_queue<int,vector<int>,greater<int> &...
优先队列
2021-08-04
1
436
题解 | #OperatingSystem#
思路 下一次出现最晚的 被 弹出队列 ==> 最佳页面置换算法 (OPT)而不是 剩余出现次数最少的 被 弹出队列 Code #include <bits/stdc++.h> using namespace std; const int N = 50010; struct ...
单调队列
2021-08-04
2
452
题解 | #老子的全排列呢#
思路 递归 Code #include <bits/stdc++.h> using namespace std; const int N = 20; bool st[N]; void dfs(int u,string s){ if(u==8) { for(...
递归
dfs
2021-08-03
2
551
首页
上一页
1
2
3
4
5
6
下一页
末页