10 2016 档案
摘要:当题目是区间求和或者其他区间询问时,如果询问是离线的,而且询问涉及 l-r内有多少个不同的xxx。这个xxx可以是不同的数 不同的gcd 不同的异或和 等等 这时候我们可以把询问按右端点排序,然后把a[i]的出现永远存在靠右的一边 当i==q.r的时候 求答案 有三道例题 hdu3333 1 Pro
阅读全文
摘要:1-1e9的数据范围 但有1e5个区间 所以可以考虑把没有涉及到的区间缩成一个点 然后树状数组求逆序对 1 #include<bits/stdc++.h> 2 3 #define inf 0x3f3f3f3f 4 5 const int maxn=1000000; 6 7 using namespa
阅读全文
摘要:因为整个序列为一个1-n的排列,所以可以这样dp dp[i][j]代表长度为i,以数字j结尾的子序列 dp[i][j]=dp[i-1][1,2,3...j-1]; 这道题的答案就是 dp[k+1][1...n]; 用树状数组求一下前缀和
阅读全文
摘要:#include #define inf 0x3f3f3f3f const int maxn=10000; using namespace std; struct node{ node* left; node* right; int value,fix,s,cnt; node(int _value,int _fix,int _s,int _cnt):value(_...
阅读全文
摘要:#include <cstdio> #include <queue> #include <algorithm> #include <string.h> //#include <bits/stdc++.h> using namespace std; const int maxn=100000; int
阅读全文
摘要:给一段序列,给你去掉所有数字的顺序,输出每去掉一个数,当前联通的子序列的最大值。 倒着来,每次插入一个数,然后求联通的最大值,线段树每个节点标记一下,区间的左右是否插入了数字,还有如果有数字从左边/右边开始连续子序列的值,还有这个节点的区间是否连续。 1 #include <cstdio> 2 3
阅读全文