Codeforces 959F Mahmoud and Ehab and yet another xor task 线性基 (看题解)

时间:2022-08-27 09:46:08

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&plus;dp&lpar;递推形&rpar;&plus;离线

    959F - Mahmoud and Ehab and yet another xor task xor+dp+离线 题意 给出 n个值和q个询问,询问l,x,表示前l个数字子序列的异或和为x的子序列 ...

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

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

  3. Codeforces 959D&period; Mahmoud and Ehab and another array construction task&lpar;构造&comma; 简单数论&rpar;

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

  4. &lbrack;CF959F&rsqb;Mahmoud and Ehab and yet another xor task题解

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

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

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

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

    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. app进入后台之后接收到通知&comma;点进去进入新的页面&comma;再次进入后台&comma;再点击通知进入页面&lpar;&comma;两次通过通知进入的页面&comma;创建了两次&comma;会多一个页面&comma;&rpar;解决办法监听

    在点击通知进入的页面的 //UIApplicationWillResignActiveNotification是app即将进入后台的方法 //增加监听使它在进入后台之前pop上一个页面 - (void ...

  2. JavaScript杂谈(顺便也当知识积累)

    JavaScript版本 JavaScript的普及使得其于1997年正式成为国际标准,其官方名称为ECMAScript 1999年定稿第三版ECMAScript标准,简称ES3 2009年重大改进的 ...

  3. iOS开发——View的透明属性hidden、alpha、opaque

    Hidden.Alpha.Opaque的区别 在iOS中,每个View都有Hidden.Alpha.Opaque三个关于透明的属性,官方文档介绍如下: 1. @property(nonatomic) ...

  4. A Tour of Go Structs

    A struct is a collection of fields. (And a type declaration does what you'd expect.) package main im ...

  5. poco vs Boost

    Wooce Yang收集整理 POCO的优点: 1) 比boost更好的线程库,特别是一个活动的方法的实现,并且还可设置线程的优先级. 2) 比 boost:asio更全面的网络库.但是boost:a ...

  6. &lbrack;转&rsqb;组合数取模 Lucas定理

    对于C(n, m) mod p.这里的n,m,p(p为素数)都很大的情况.就不能再用C(n, m) = C(n - 1,m) + C(n - 1, m - 1)的公式递推了. 这里用到Lusac定理 ...

  7. laytpl&period;js 模板使用记录

    {{# for(var j = 0, len = d.length; j < len; j++){ }} <div class="pure-u-1-5 pure-u-sm-1 p ...

  8. Troubleshooting OpenStack 瘫痪 - 每天5分钟玩转 OpenStack(160)

    这是 OpenStack 实施经验分享系列的第 10 篇.是软件就会有 bug,OpenStack 也不例外,只要用它就一定会遇到故障.Troubleshooting(故障排除)是运维 OpenSta ...

  9. git连接不上远程仓库---visualstudio提交代码报错:no upstream configured for branch &&num;39&semi;master&&num;39&semi;

    1,新建文件夹,在文件下下鼠标右键git bush--->git init,初始化仓库: 2,设置gitthub仓库地址:git remote add origin https://github ...

  10. C&num;获取文件目录

    Form1.cs using System;using System.Collections.Generic;using System.ComponentModel;using System.Data ...