CodeForces 1100F Ivan and Burgers
CodeForces题面
Time limit 3000 msMemory limit 262144 kB
Source Codeforces Round #532 (Div. 2)
Tags data structures divide and conquer greedy math *2600
Editorial
- Announcement #1 (en)
- Announcement #2 (ru)
- Tutorial #1 (en)
- Tutorial #2 (ru)
- Tutorial #3 (en)
中文题意
英文题面还是没读太懂……其他博客是这么说的——一个长度为\(n\)的序列,\(m\)个询问,每次询问一个区间内数字的异或最大值。
解题思路
我用的下面第一个思路,还没仔细想证明啊……为什么可以直接把线性基里靠前的那些替换掉而不改变线性基的性质呢……
- 最普遍的在线维护线性基的思路
- https://www.luogu.org/problemnew/solution/CF1100F 八仙过海
- 上面那个最常见在线思路的
- 线段树离线维护的
- 序列看成树进行点分治的
- 整体二分的
- lxl ST表的(分块那么万能的吗)
- ………………
又有了4道题可以补了
- [x] CodeForces 1100F 单纯询问区间异或最大值
- [ ] HDU 6579 多了个末尾插入数据的操作,还有强制在线
- [ ] BZOJ 4184 这题还多了插入和删除的操作。居然是权限题……本地测一下算了。
- [ ] UVALive 8514 2017ICPC西安的一道题,操作都差不多
源代码
#include
#include
#include
const int MAXN=1e6+5;
const int wide=31;
int T;
int n,m;
int p[MAXN][wide+2],pos[MAXN][wide+2];
void insert(int loc,int val)//location和value
{
for(int i=wide;~i;i--)
{
p[loc][i]=p[loc-1][i];
pos[loc][i]=pos[loc-1][i];
}
int temp=loc;
for(int i=wide;~i;i--)
{
if((val>>i)&1)
{
if(!p[loc][i])
{
p[loc][i]=val;
pos[loc][i]=temp;
return;
}
if(pos[loc][i]ans&&pos[r][i]>=l)
ans^=p[r][i];
}
printf("%d\n",ans);
}
return 0;
}