随笔分类 - CF
摘要:1 #include<iostream> 2 #include<cstring> 3 #include<string> 4 #include<cmath> 5 #include<cstdio> 6 #include<queue> 7 #define ll long long 8 #define IN
阅读全文
摘要:1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cmath> 5 #include<string> 6 using namespace std; 7 8 const int N = 2e5 + 10;
阅读全文
摘要:dfs一次解决sum 第二次解决已处理的点的顺序以及未处理的点的顺序 已处理,则存入队列,靠近叶子的点先出 未处理,则存入栈,靠近顶端的点先出 一共跑了三次树 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #incl
阅读全文
摘要:本题中n一定为奇数,因而观察半部分图形即可。 下图中以十边形为例: 只需要当长度与高度相等时,必是套上正方形最小。 然后手动算算 cos(alpha) * x = cos(pi / n / 2 - alpha) * x 则alpha = pi / n / 4 然后再代入算一下就是了 1 #inclu
阅读全文
摘要:傻咯 写了半个下午的DP,在第四个点就WA了 还是逃不过看题解 DFS下推,将最小值尽可能下传覆盖,因为对于靠近叶子节点的点,既然顶端的花费比父亲的花费更小,我们当然选择上面更小的最优。 DFS上推返回直接求解,利用pair维护每个节点原先b状态1的个数以及所需c状态1的个数,如果某个节点二者均不为
阅读全文
摘要:1 #include<bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 const int INF = 1e9; 5 const int N = 1e5 + 10; 6 int a[N]; 7 int n; 8 9 int
阅读全文
摘要:1 #include<bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 const ll INF = 1e18; 5 const int N = 1e5 + 10; 6 int n, m, t; 7 ll a[N], b[N
阅读全文
摘要:1 #include<bits/stdc++.h> 2 #define ll long long 3 #define INF 1e17 4 using namespace std; 5 const int N = 2e5 + 10; 6 ll n, k; 7 ll a[N]; 8 9 bool ch
阅读全文
摘要:思维题 找规律 注意变与不变的量 列出变化的量之间的关系 找到变中的不变 答案就有了 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N = 1e5 + 10; 4 int a[N],b[N]; 5 vector<int>v1
阅读全文
摘要:单调栈 + dp dp蛮好想的 单调栈需要注意,此题要求i由j转移而得的条件为: 1. j == i - 1 2. i, j位置的h较小值必须大于二者之间序列内的最大值 3. i, j位置的h较大值必须小于二者之间序列内的最小值 满足任意一条即可转移 而 对于相同高度的元素,则不能同时出现在栈内。因
阅读全文
摘要:永远无法理解的题 分治 单调栈 笛卡尔树 1 #include<iostream> 2 #include<algorithm> 3 #include<cmath> 4 #include<stack> 5 #include<cstring> 6 using namespace std; 7 const
阅读全文
摘要:看到这题就想到之前做过的一道字符串异或判断是否经过排列能形成回文结构。 可惜没想到用vector来维护相同深度的节点,以及使用in/out判断是否位于子树内的特殊操作。 甚至蛮好理解? 1 #include<iostream> 2 #include<algorithm> 3 #include<cst
阅读全文
摘要:组合数 + dp思想 先将所有黑点排个序,左上方的优先级最高 则确保对于当前黑点,它所能到达的黑点必定位于排序后序列中的它的后方 然后将(h, w)加入到序列尾端 ++n 对于该序列中的每一个节点( j ),初状态为从(1, 1)抵达该点的方案数,即初始化type[ i ] 但这时会有重复计算。从(
阅读全文
摘要:1 vector<int> v; 2 v.clear(); 3 vector<int>::iterator it; 4 for(int j = l + 1 ; j < r ; j++){ 5 if(a[j] >= a[l] && a[j] <= a[r]){ 6 it = upper_bound(v
阅读全文
摘要:对不起我硕哥 思路全对,就是个组合数的事情 减操作取模记得+mod!!! 1 #include<bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 5 const int maxn = 1e6 + 10; 6 const ll
阅读全文
摘要:上图来源于标程解析 CF 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<vector> 5 #define ll long long 6 #define fir first 7 #define sec
阅读全文
摘要:1408D - Searchlights Let's define as xx our move to the right and as yy our move to the up. For all pairs (i,j)(i,j) of (robber, searchlight) at least
阅读全文
摘要:CF1353E 1 for(int i = 1 ; i <= n ; i++){ 2 dp[i][0] = min(dp[i - 1][1], dp[i - 1][0]) + (s[i] == '1'); 3 if(i >= k) dp[i][1] = dp[i - k][1] + sum[i -
阅读全文
摘要:做过一点点构造题,花了一个小时想怎么构造,但并没有什么用,写起来感觉有点复杂。 标程分析: 对于输出结果,共d次分配情况。而对于每个学生而言,每个人有d次选择乘坐车辆的机会。 那么所有同学在k辆车,d轮下的选车情况共有k的d次方种选法。 仔细想一想,如果学生的数量超过了上述选法种数,根据鸽巢原理,必
阅读全文
摘要:区间dp 注意len==2的特判问题 1 #include<iostream> 2 #include<algorithm> 3 #include<cmath> 4 #include<cstdio> 5 #define INF 1e9 6 using namespace std; 7 const in
阅读全文

浙公网安备 33010602011771号