[CF482B]Interesting Array】的更多相关文章

题目大意:构造一个序列$S$,有$m$条限制,每条为$l\;r\;q$,表示$\&_{i=l}^r S_i=q$ 题解:每条限制就把$[l,r]$内的数或上$q$,最后判断就行了 卡点:我又写了一课$O(n^2\log_2n)$的线段树... C++ Code: #include <cstdio> #include <cstdlib> #define maxn 100010 const int inf = (1 << 30) - 1; namespace SgT…
题目链接:Codeforces 482B Interesting Array 题目大意:给定一个长度为N的数组,如今有M个限制,每一个限制有l,r,q,表示从a[l]~a[r]取且后的数一定为q,问是 否有满足的数列. 解题思路:线段树维护.每条限制等于是对l~r之间的数或上q(取且的性质,对应二进制位一定为1).那么处理全然部的 限制.在进行查询.查询相应每一个l~r之间的数取且是否还等于q.所以用线段树维护取且和.改动为或操作. #include <cstdio> #include <…
题目:codeforces 482B. Interesting Array 题意:给你一个值n和m中操作,每种操作就是三个数 l ,r,val. 就是区间l---r上的与的值为val,最后问你原来的数组是多少?假设不存在输出no 分析:分析发现要满足全部的区间,而一个点上假如有多个区间的话,这个点的值就是全部区间或的值.由于仅仅有这样才干满足全部区间的.把全部位上的1都保存下来了.那么能够发现用线段树来维护,可是那么怎么推断满不满足条件呢?能够也用线段树,更新了之后在整个维护一遍看看满不满足题意…
题目链接 Interesting Array 区间更新.然后对于每一个约数重新求一遍区间的&值,不符合就跳出. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define lson i << 1, L, mid #define rson i << 1 | 1, mid + 1, R ; struct node…
题目描述: D. Interesting Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of t…
B. Interesting Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of…
题意: 构造一个序列,满足m个形如:[l,r,c] 的条件. [l,r,c]表示[l,r]中的元素按位与(&)的和为c. 解法: 线段树维护,sum[rt]表示要满足到现在为止的条件时该子树的按位与和至少为多少. 更新时,如果val的pos位为1,那么整个区间的按位与和pos位也应该为1,否则与出来就不对了.(这是本题解题的核心) 那么此时更新 sum[rt] |= val 即可.然后再check一遍看是否满足所有条件即可. 代码: #include <iostream> #inclu…
题意:构造一个长度为n的序列,使其满足m个形式如下如下约束:a[l]&a[l+1]&a[l+2]&....&a[r]=q 从Dalao的博客上看到这题,决定去水水.做法比较显然,就是做一些区间or之后判断一下之前的条件是否满足.用线段树维护即可. 不出意外,我的线段树又调爆了,因为我把<<打成了>>.... #include<bits/stdc++.h> using namespace std; #define MAXN 1000000+…
前言 JSON崛起不是意外,是顺应时代;相当简洁小巧的书写模式及阅读方式; 基础 看这篇文章: JSON知识点汇总_W3SCHOOL 初步进阶 早期的解析仅仅实用eval() ,可是这货太easy给注入恶意代码-之后就有人写了个JSON2.js来让低级浏览器支持JSON ES5開始,就出现了对应的规范来和函数处理JSON对象[stringify()和parse()]; 值得一提的是: 1. 每一个属性名都必须用双引號或单引號,否则会抛出异常!!! 2. JSON数组的格式为字面量格式 3. 每一…
题目链接:http://codeforces.com/contest/483 A - Counterexample - [简单构造题] Your friend has recently learned about coprime numbers. A pair of numbers $(a, b)$ is called coprime if the maximum number that divides both $a$ and $b$ is equal to one. Your friend…