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 线性基 (看题解)的更多相关文章

  1. 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的子序列 ...

  2. Codeforces 959 F. Mahmoud and Ehab and yet another xor task

    \(>Codeforces\space959 F. Mahmoud\ and\ Ehab\ and\ yet\ another\ xor\ task<\) 题目大意 : 给出一个长度为 \ ...

  3. Codeforces 959D. Mahmoud and Ehab and another array construction task(构造, 简单数论)

    Codeforces 959D. Mahmoud and Ehab and another array construction task 题意 构造一个任意两个数都互质的序列,使其字典序大等于a序列 ...

  4. [CF959F]Mahmoud and Ehab and yet another xor task题解

    搞n个线性基,然后每次在上一次的基础上插入读入的数,前缀和线性基,或者说珂持久化线性基. 然后一个num数组记录当时线性基里有多少数 然后每次前缀操作一下就珂以了 代码 #include <cs ...

  5. codeforces-473D Mahmoud and Ehab and another array construction task (素数筛法+贪心)

    题目传送门 题目大意:先提供一个数组,让你造一个数组,这个数组的要求是 1 各元素之间都互质  2  字典序大于等于原数组  3 每一个元素都大于2 思路: 1.两个数互质的意思就是没有公因子.所以每 ...

  6. D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学

    D. Mahmoud and Ehab and another array construction task 因子分解模板 题意 给出一个原序列a 找出一个字典序大于a的序列b,使得任意 \(i!= ...

  7. 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 ...

  8. Codeforces 862B - Mahmoud and Ehab and the bipartiteness

    862B - Mahmoud and Ehab and the bipartiteness 思路:先染色,然后找一种颜色dfs遍历每一个点求答案. 代码: #include<bits/stdc+ ...

  9. Codeforces 862C - Mahmoud and Ehab and the xor

    862C - Mahmoud and Ehab and the xor 思路:找两对异或后等于(1<<17-1)的数(相当于加起来等于1<<17-1),两个再异或一下就变成0了 ...

随机推荐

  1. 【转】BTree,B-Tree,B+Tree,B*Tree

    B树: 即二叉搜索树: 1.所有非叶子结点至多拥有两个儿子(Left和Right): 2.所有结点存储一个关键字: 3.非叶子结点的左指针指向小于其关键字的子树,右指针指向大于其关键字的子树: 如: ...

  2. keras使用

    一.pad_sequences from keras.preprocessing.sequence import pad_sequences keras只能接受长度相同的序列输入.因此如果目前序列长度 ...

  3. mac 连接linux服务器,用scp命令实现本地文件与服务器文件之间的互相传输

    mac连接linux服务器 打开终端,切换到root权限下,切换root权限命令:sudo -i 通过ssh命令连接linux服务器:ssh root@ip地址(root是账户名) 然后根据提示输入密 ...

  4. docker时间与系统时间同步的问题

    系统是CentOS7,因为开发环境是windows没有这个问题,发布到docker以后当前时间进行比较,发现docker里面用java获取当时间不对,然后查docker的时间少了8个小时. 网上查了很 ...

  5. Dynamics CRM 如何修复 Access Is Denied - ObjectTypeCode: 2500 的错误

    最近被 Dynamics CRM 的权限配置问题恶心了一个星期,老是报“Access Is Denied”,几经波折,最后终于找到一个比较合适的解决方案,写个博客 mark 下来,方便以后查看. 首先 ...

  6. Mysql查询库、表存储量(Size)

    Mysql查询库.表存储量(Size) 1.要查询表所占的容量,就是把表的数据和索引加起来就可以了. SELECT SUM(DATA_LENGTH) + SUM(INDEX_LENGTH) FROM ...

  7. ioctl函数

    一.函数原型 #include <unistd.h> int ioctl(int fd, int request, .../* void *arg */); 二.和网络相关的请求(requ ...

  8. (三)初探maven之使用IDE

    一.在IDE中使用maven 打开Eclipse,在菜单栏依次选中window   => preferences  => Maven  => Installations , 然后添加 ...

  9. (四)Python中的“四大才子”(字符串、列表、字典、集合)

    前戏:在python中把数据序列分为可变(mutable)和不可变(immutable)两种 不可变:string.int.float.tuple 特点:相同对象只是占用一个内存地址,不管有多少个变量 ...

  10. 2018-2019-2 网络对抗技术 20165237 Exp3 免杀原理与实践

    2018-2019-2 网络对抗技术 20165237 Exp3 免杀原理与实践 一.实践目标 1.1 正确使用msf编码器,msfvenom生成如jar之类的其他文件,veil-evasion,加壳 ...