51nod 1577 线性基
思路:
http://blog.csdn.net/yxuanwkeith/article/details/53524757
//By SiriusRen
#include <bits/stdc++.h>
using namespace std;
const int N=;
int n,m,a[N];
inline int read(){
int x=;char p=getchar();
while(p<''||p>'')p=getchar();
while(p>=''&&p<='')x=x*+p-'',p=getchar();
return x;
}
struct Node{int wei,id;Node(){}Node(int x,int y){wei=x,id=y;}}f[N][];
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++)a[i]=read();
for(int i=n;i;i--){
memcpy(f[i],f[i+],sizeof(f[i]));
Node now=Node(a[i],i);
for(int j=;~j;j--)if(now.wei&(<<j)){
if(f[i][j].wei){
if(now.id<f[i][j].id)swap(f[i][j],now);
now.wei^=f[i][j].wei;
}
else{
f[i][j]=now;
break;
}
}
}
scanf("%d",&m);
while(m--){
int l,r,x;
l=read(),r=read(),x=read();
for(int i=;~i;i--)if(x&(<<i)){
if(!f[l][i].wei||f[l][i].id>r)break;
x^=f[l][i].wei;
}
puts(!x?"YES":"NO");
}
}
51nod 1577 线性基的更多相关文章
- 51nod 1577 异或凑数 线性基的妙用
\(OTZgengyf\)..当场被吊打\(QwQ\) 思路:线性基 提交:\(3\)次 错因:往里面加数时\(tmp.p\)与\(i\)区分不清(还是我太菜了) 题解: 我们对每个位置的线性基如此操 ...
- BZOJ 2844 albus就是要第一个出场 ——高斯消元 线性基
[题目分析] 高斯消元求线性基. 题目本身不难,但是两种维护线性基的方法引起了我的思考. void gauss(){ k=n; F(i,1,n){ F(j,i+1,n) if (a[j]>a[i ...
- BZOJ 2115 [Wc2011] Xor ——线性基
[题目分析] 显然,一个路径走过两边是不需要计算的,所以我么找到一条1-n的路径,然后向该异或值不断异或简单环即可. 但是找出所有简单环是相当复杂的,我们只需要dfs一遍,找出所有的环路即可,因为所有 ...
- BZOJ 3105 [CQOI2013]新Nim游戏 ——线性基
[题目分析] 神奇的题目,两人都可以第一次取走足够多堆的石子. nim游戏的规则是,如果异或和为0,那么就先手必输,否则先手有必胜策略. 所以只需要剩下一群异或和为0就可以了. 先排序,线性基扫一遍即 ...
- BZOJ 2460 [BeiJing2011]元素 ——线性基
[题目分析] 线性基,由于最多有63个,只需要排序之后,动态的去维护线性基即可. [代码] #include <cstdio> #include <cstring> #incl ...
- Xor && 线性基练习
#include <cstdio> #include <cstring> ; ; int cnt,Ans,b,x,n; inline int Max(int x,int y) ...
- 【BZOJ-4568】幸运数字 树链剖分 + 线性基合并
4568: [Scoi2016]幸运数字 Time Limit: 60 Sec Memory Limit: 256 MBSubmit: 238 Solved: 113[Submit][Status ...
- 【BZOJ-2460&3105】元素&新Nim游戏 动态维护线性基 + 贪心
3105: [cqoi2013]新Nim游戏 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 839 Solved: 490[Submit][Stat ...
- 【BZOJ-2115】Xor 线性基 + DFS
2115: [Wc2011] Xor Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 2142 Solved: 893[Submit][Status] ...
随机推荐
- NumPy 学习笔记(四)
NumPy 算术函数: 1.numpy.reciprocal(arr) 返回参数逐个元素的倒数 2.numpy.power(one, two) 将第一个输入数组中的元素作为底数,计算它与第二个输入数组 ...
- circumferential averaged streamwise velocity in ParaView
Goal: get a averaged axial velocity in a circular loop (dashed line in the following figure) Steps: ...
- 3.6.5 空串与Null串
空串""是长度为0的字符串.可以调用以下代码检查一个字符串是否为空: String s = "greeting"; ...
- 【Codeforces 992B】Nastya Studies Informatics
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 因为gcd(a,b)=x 所以设a = nx b = mx 又有ab/gcd(a,b)=lcm(a,b)=y 则nmx = y 即n(m*x) ...
- springboot 2.x 集成 drools 7.x
简介:springboot 2.0.4.RELEASE 集成 drools 7.11.0.Final 1.项目结构 2. pom.xml文件 <?xml version="1.0&qu ...
- Luogu P1257 平面上的最接近点对 暴力
这道题数据不大 两点距离用勾股定理求 #include<iostream> #include<cmath> using namespace std; struct node{ ...
- JSOI最大值 (线段树)
change 单点修改 query 区间最值 Program XJOI2321; ; ..maxn*] of longint; i,m,n,ans,p,x:longint; ch:char; func ...
- T1075 明明的随机数 codevs
http://codevs.cn/problem/1075/ 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver 题目描述 Description 明明想在学校中 ...
- 洛谷—— P2047 社交网络
P2047 社交网络 题目描述 在社交网络(social network)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题.在一个社交圈子里有n个人,人与人之间有不同程度的关系. ...
- Ubuntu下常规方法安装软件
一.通过apt-get 搜索: #搜索 apt-cache searche 7zip 安装: #安装 sudo apt-get install 7zip 更新: #查看特定软件的版本,前提是要安装ap ...