Div 2 532

  • 我对交互一无所知
  • 只能寄期望与NOI和省选不出交互吧...

E

这个题,真的是耻辱...

其实非常简单,就是二分+判环...

那么就直接二分答案+拓扑排序即可...

(我居然在考试的时候没一眼秒出来...

(我居然把它跳过去了...

F

(又一次犯了同样的错误.jpg

(这个线性基真的是...

一个非常简单的$\log^2n$做法,直接线段树+线性基合并即可...

然后正解也不难,但是如果一直陷入第一个就真的想不出来.jpg

直接暴力维护后缀基+扫描线即可...

每次支持向线性基中插入即可...

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 500005
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
struct Mat
{
int a[21],siz;
Mat(){memset(a,0,sizeof(a));siz=0;}
bool insert(int x)
{
if(siz==20)return 0;
for(int i=19;~i;i--)if((x>>i)&1)
if(a[i])x^=a[i];
else {a[i]=x;siz++;return 1;}
return 0;
}
void calc(int &x){for(int i=19;~i;i--)if((!((x>>i)&1))&&a[i])x^=a[i];}
int calc(){int x=0;for(int i=19;~i;i--)if(!((x>>i)&1)&&a[i])x^=a[i];return x;}
}t[N];
int a[N],n,lst[22],ans[N],Q;
struct node{int l,r,idx;}q[N];
inline bool cmp(const node &a,const node &b){return a.r==b.r?a.l<b.l:a.r<b.r;}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
scanf("%d",&Q);
for(int i=1;i<=Q;i++)scanf("%d%d",&q[i].l,&q[i].r),q[i].idx=i;sort(q+1,q+Q+1,cmp);
for(int i=1,k=1;i<=n;i++)
{
if(!lst[0])lst[0]=i;
// printf("%d\n",i);
for(int j=19;j;j--)if(lst[j])
{
if(t[lst[j]].insert(a[i]))
{
if(!lst[j+1])lst[j+1]=lst[j];
// if(lst[j]==3)printf("%d\n",a[i]);
lst[j]++;
while(lst[j]<lst[j-1]&&t[lst[j]].insert(a[i]))
{
// if(lst[j]==3)printf("%d\n",a[i]);
// if(lst[j]==4)printf("%d\n",a[i]);
lst[j]++;
}
if(lst[j]==lst[j-1])lst[j]=0;
}
}
if(t[lst[0]].insert(a[i]))
{
if(!lst[1])lst[1]=lst[0];lst[0]++;
while(lst[0]<=i&&t[lst[0]].insert(a[i]))
{
// if(lst[0]==3)printf("%d\n",a[i]);
// if(lst[0]==4)printf("%d\n",a[i]);
lst[0]++;
}
if(lst[0]==i+1)lst[0]=0;
}
// for(int j=5;j;j--)printf("j=%d lst[j]=%d\n",j,lst[j]);
while(k<=Q&&q[k].r==i)t[q[k].l].calc(ans[q[k].idx]),k++;
}
// printf("%d %d\n",t[4].siz,t[3].siz);
for(int i=1;i<=Q;i++)printf("%d\n",ans[i]);
}
/*
10
32 52 25 0 1 9 8 16 64 16
10
2 7
2 6
6 8
1 1
5 10
5 8
4 10
6 8
2 6
6 10
*/

Codeforces round 1100的更多相关文章

  1. CodeForces Round

    CodeForces Round 199 Div2   完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions     # When Who Problem ...

  2. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  3. Codeforces Round #532 (Div. 2) 题解

    Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...

  4. Codeforces Round #564 (Div. 1)

    Codeforces Round #564 (Div. 1) A Nauuo and Cards 首先如果牌库中最后的牌是\(1,2,\cdots, k\),那么就模拟一下能不能每次打出第\(k+i\ ...

  5. Codeforces Round #721 (Div. 2)A. And Then There Were K(位运算,二进制) B1. Palindrome Game (easy version)(博弈论)

    半个月没看cf 手生了很多(手动大哭) Problem - A - Codeforces 题意 给定数字n, 求出最大数字k, 使得  n & (n−1) & (n−2) & ...

  6. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. js-ES6学习笔记-变量的解构赋值

    1.ES6 允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构(Destructuring). 2.ES6允许写成:let [a,b,c] = [1,2,3];上面代码表示,可以从数 ...

  2. js-对象深度克隆方法

    学习收藏. 1.来自http://www.cnblogs.com/yxz-turing/p/4784861.html function cloneObj(obj){ var str, newobj = ...

  3. CSS中的三种常用定位

    一.相对定位(position:relative) 如果想让一个元素在本来的位置进行一个位移,可以将该元素的定位设置为relative,同时指定相对位移(利用top,bottom,left,right ...

  4. 跨域cors中如何传递cookie(前端为什么无法向后端传递cookie?)

    没有跨域 后端server只要在回应头部‘set-cookie’,那么就会有cookie产生并保存在客户端client. 等到client再次向后端server发送请求时浏览器的机制就会自动携带coo ...

  5. 葡萄城报表 SP2新特性(2)— 智能钻取下级报表

    中国式复杂报表常常会因为一些特殊的行业规范存在着一些复杂的需求,对于报表的功能要求不仅要广而全,还要精细到行业内部,葡萄城报表近几年来也一直致力于解决中国式复杂报表的需求,一直持续增强中国式复杂报表的 ...

  6. 敏捷开发的道与术---MPD软件工作坊培训感想(上)

    注:由麦思博(MSUP)主办的2013年亚太软件研发团队管理峰会(以下简称MPD大会)分别于6月15及6月22日在北京.上海举办,葡萄城的部分程序员参加了上海的会议,本文是参会的一些感受和心得. 这次 ...

  7. Mariadb MySQL、Mariadb中GROUP_CONCAT函数使用介绍

    MySQL.Mariadb中GROUP_CONCAT 函数使用介绍 By:授客 QQ:1033553122 语法: GROUP_CONCAT([DISTINCT] column_name [ORDER ...

  8. 大数据【六】ZooKeeper部署

    这是一个分布式服务框架,阿帕奇的一个子项目.关于ZooKeeper我只简单的部署一下,以便后面的HBase. 一  概述 ZooKeeper 分布式服务框架是 Apache Hadoop 的一个子项目 ...

  9. RecyclerView打造通用的万能Adapter

    既然想做到通用那么现在摆在面前的就三个问题:数据怎么办?布局怎么办? 绑定怎么办?.数据决定采用泛型,布局打算直接构造传递,绑定显示效果肯定就只能回传. 1 基本改造 数据决定采用泛型,布局打算直接构 ...

  10. 【Redis】Redis学习(五) Redis cluster模式详解

    一般情况下,使用主从模式加Sentinal监控就可以满足基本需求了,但是当数据量过大一个主机放不下的时候,就需要对数据进行分区,将key按照一定的规则进行计算,并将key对应的value分配到指定的R ...