摘要:
求多个数最大值: max({......}); 转换成滚动数组 将数组第一维改为2,在每次循环开始前清空下数组,每个第一维都与上一个1。 修改后 int f[2][4]; for (int i = 1; i <= n; i ++ ) { memset(f[i + 1 & 1], 0, sizeof 阅读全文
摘要:
A-青年歌手大赛-评委会打分 用mx记录最大值,mi记录最小值,all记录和,最后all再减掉mx,mi,再取平均值。 #include <bits/stdc++.h> using namespace std; #define int long long const int inf = 0x3f3f 阅读全文
摘要:
使用C++ STL中的list<int> li为例。 list.insert(it, x)的解释 在it所对应的节点的前面插入节点x。 注:list.begin()对应链表中第一个节点。 头插法 li.push_front(x); // li.insert(li.begin(), x); 尾插法 l 阅读全文
摘要:
洛谷-1020 思路 由这篇blog可以知道本题求的就是 最长上升子序列 和 最长下降子序列 的长度。 采用的是 的做法。 有一个问题,在求最长上升子序列的过程中,用到了lower_bound函数,求第一个大于等于t的数; 这里不能使用upper_bound函数,因为它求的是第一个 阅读全文
摘要:
HDU-1257 思路 最少需要的防御系统个数就是最大上升子序列的长度。(Dilworth定理) 这篇blog介绍了Dilworth定理。 Code 的LIS #include <bits/stdc++.h> using namespace std; #define _u_u_ io 阅读全文
摘要:
# 数据结构课程-关键路径 ## 拓扑排序 判环 + bfs(栈实现) ```cpp #include using namespace std; inline void _A_A_(); signed main() {_A_A_();return 0;} const int maxn = 1e3 + 阅读全文
摘要:
洛谷-1347 思路 此题解的思路再加上这篇blog的代码实现。 注意:本题要求的不是一个拓扑排序就可以了,实际上是要求一条链的拓扑排序。 Code #include <bits/stdc++.h> using namespace std; #define _u_u_ ios::sync_with_ 阅读全文