Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)
Mahmoud and Ehab and yet another xor task
存在的元素的方案数都是一样的, 啊, 我好菜啊。
离线之后用线性基取check存不存在,然后计算答案。
#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define ull unsigned long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define fio ios::sync_with_stdio(false); cin.tie(0); using namespace std; const int N = 1e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); template<class T, class S> inline void add(T& a, S b) {a += b; if(a >= mod) a -= mod;}
template<class T, class S> inline void sub(T& a, S b) {a -= b; if(a < ) a += mod;}
template<class T, class S> inline bool chkmax(T& a, S b) {return a < b ? a = b, true : false;}
template<class T, class S> inline bool chkmin(T& a, S b) {return a > b ? a = b, true : false;} int n, q, a[N], ans[N];
vector<int> base;
vector<PII> qus[N]; int ok(int v) {
for(auto& x : base) v = min(v, v ^ x);
return v;
} int main() {
scanf("%d%d", &n, &q);
for(int i = ; i <= n; i++) scanf("%d", &a[i]);
for(int i = ; i <= q; i++) {
int l, x; scanf("%d%d", &l, &x);
qus[l].push_back(mk(x, i));
}
int way = ;
for(int i = ; i <= n; i++) {
int val = ok(a[i]);
if(!val) way = 1LL * way * % mod;
else base.push_back(val);
for(auto& q : qus[i]) ans[q.se] = ok(q.fi) ? : way;
}
for(int i = ; i <= q; i++) printf("%d\n", ans[i]);
return ;
} /*
*/
Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)的更多相关文章
- 959F - Mahmoud and Ehab and yet another xor task xor+dp(递推形)+离线
959F - Mahmoud and Ehab and yet another xor task xor+dp+离线 题意 给出 n个值和q个询问,询问l,x,表示前l个数字子序列的异或和为x的子序列 ...
- Codeforces 959 F. Mahmoud and Ehab and yet another xor task
\(>Codeforces\space959 F. Mahmoud\ and\ Ehab\ and\ yet\ another\ xor\ task<\) 题目大意 : 给出一个长度为 \ ...
- Codeforces 959D. Mahmoud and Ehab and another array construction task(构造, 简单数论)
Codeforces 959D. Mahmoud and Ehab and another array construction task 题意 构造一个任意两个数都互质的序列,使其字典序大等于a序列 ...
- [CF959F]Mahmoud and Ehab and yet another xor task题解
搞n个线性基,然后每次在上一次的基础上插入读入的数,前缀和线性基,或者说珂持久化线性基. 然后一个num数组记录当时线性基里有多少数 然后每次前缀操作一下就珂以了 代码 #include <cs ...
- codeforces-473D Mahmoud and Ehab and another array construction task (素数筛法+贪心)
题目传送门 题目大意:先提供一个数组,让你造一个数组,这个数组的要求是 1 各元素之间都互质 2 字典序大于等于原数组 3 每一个元素都大于2 思路: 1.两个数互质的意思就是没有公因子.所以每 ...
- D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学
D. Mahmoud and Ehab and another array construction task 因子分解模板 题意 给出一个原序列a 找出一个字典序大于a的序列b,使得任意 \(i!= ...
- Codeforces 862A Mahmoud and Ehab and the MEX
传送门:CF-862A A. Mahmoud and Ehab and the MEX time limit per test 2 seconds memory limit per test 256 ...
- Codeforces 862B - Mahmoud and Ehab and the bipartiteness
862B - Mahmoud and Ehab and the bipartiteness 思路:先染色,然后找一种颜色dfs遍历每一个点求答案. 代码: #include<bits/stdc+ ...
- Codeforces 862C - Mahmoud and Ehab and the xor
862C - Mahmoud and Ehab and the xor 思路:找两对异或后等于(1<<17-1)的数(相当于加起来等于1<<17-1),两个再异或一下就变成0了 ...
随机推荐
- SaltStack配置管理和YAML
配置管理和YAML 配置管理 所谓的配置管理,也称为状态管理,就是可以通过编写文件,文件的内容为安装什么功能.开启什么服务,执行什么任务等信息,然后通过salt的配置管理,指定minion来执行这些操 ...
- 第六周java学习总结
学号 20175206 <Java程序设计>第六周学习总结 教材学习内容总结 第七章: 主要内容 内部类 匿名类 异常类 断言 重点和难点 重点:内部类和异常类的理解 难点:异常类的使用 ...
- 同样级别iOS程序员,为啥比我菜的程序员薪资都比我高?
前言: 作为程序员,都有一种相同的焦虑——即当一次又一次的新技术浪潮袭来,总会不由自主的拼命跟随,总是担心如果不紧跟新技术的潮流,将会被时代所抛弃. 害怕年龄,害怕平庸,其实只是你在现实里的努力无法支 ...
- Linux Centos7.x下安装部署VNC的实操详述
VNC (Virtual Network Console)是虚拟网络控制台的缩写.它 是一款优秀的远程控制工具软件,由著名的AT&T的欧洲研究实验室开发的.VNC 是在基于 UNIX和 Lin ...
- OS + CentOS / windows / xrdp / vnc
s 通过windows远程访问linux桌面的方法(简单) https://www.cnblogs.com/lizhangshu/p/9709531.html https://dl.fedorapro ...
- Shell中的算数运算
加法 echo $((a+b)) expr $a + $b let "a=1+2";echo $a a=;let "a+=10";echo $a echo &q ...
- ES 常用java api
java rest client 有两种: 1.Java Low Level REST Client :用于Elasticsearch的官方低层客户端.它允许通过http与Elasticsearch集 ...
- IDEA 导入 Tomcat9 源码
源码下载(Source Code Distributions)地址:https://tomcat.apache.org/download-90.cgi tomcat 和 servlet 以及 jdk ...
- Hadoop记录-queue使用率
#!/bin/sh ip=xxx port=8088 export HADOOP_HOME=/app/hadoop/bin rmstate1=$($HADOOP_HOME/yarn rmadmin - ...
- 爬虫框架Scrapy 之(二) --- scrapy文件
框架简介 核心部分: 引擎.下载器.调度器 自定义部分: spider(自己建的爬虫文件).管道(pipelines.py) 目录结构 firstSpider firstSpider spiders ...