题目链接: http://codeforces.com/contest/1174/problem/D 题意: 构造一个序列,满足以下条件 他的所有子段的异或值不等于$x$ $1 \le a_i<2^n$ 输出一个最长的这样的序列 数据范围: $1 \le n \le 18$$1 \le x<2^{18}$ 分析: 比赛的时候搞混$subsegment$和$subsequence$,前者为子段一定要连续,后者为子序列可以不连续 赛后看的官方题解 假设构造的序列为$a_i$,它的前缀异或和为$b_…
题面 Given two integers \(n\) and \(x\), construct an array that satisfies the following conditions: ·for any element ai in the array, \(1≤ai<2^n\); ·there is no non-empty subsegment with bitwise XOR equal to \(0\) or \(x\), ·its length \(l\) should be…
题中只有两个条件:任意区间异或值不等于0或m. 如果只考虑区间异或值不等于 0,则任意两个前缀异或值不能相等. 而除了不能相等之外,还需保证不能出现任意两个前缀异或值不等于m. 即 $xor[i]$^$xor[j]!=m$, $\Rightarrow$ m^xor[j] 这个异或前缀就不可以再次出现了. 用一个数组标记一下就好了~ #include <bits/stdc++.h> #define N 1000000 #define setIO(s) freopen(s".in&quo…
题目链接 边颓边写了半上午A掉啦233(本来就是被无数人过掉的好吗→_→) 首先可以\(Query\)一次得到\(a,b\)的大小关系(\(c=d=0\)). 然后发现我们是可以逐位比较出\(a,b\)在这每位上的大小关系的. 最后还剩下\(a,b\)相等的位需要再判断是\(0\)还是\(1\),\(a,b\)分别异或一个\(1,0\)就可以了(假如都是\(0,0\),那异或之后\(1,0\)是\(a>b\):如果都是\(1,1\),异或之后就是\(0,1\),\(a<b\)). 询问次数\(…
思路: 使用前缀和技巧进行问题转化:原数组的任意子串的异或值不能等于0或x,可以转化成前缀异或数组的任意两个元素的异或值不能等于0或x. 实现: #include <bits/stdc++.h> using namespace std; << ]; int main() { int n, x; while (cin >> n >> x) { memset(vis, , sizeof vis); vector<int> v; << n)…
做法 求出答案序列的异或前缀和\(sum_i\),\([l,r]\)子段异或和可表示为\(sum_r\bigoplus sum_{l-1}\) 故转换问题为,填\(sum\)数组,数组内的元素不为\(0\)且互不相同,且两两异或不为\(x\) 预处理\(x\)为多对值,每对值异或起来为\(x\),显然是两两互不影响的,每对值选择任意一个填就行了 最后还得从\(sum_i=\bigoplus_{j=1}^i a_i\)转换为\(a_i\) code #include<bits/stdc++.h>…
题目大意: 本题有两个隐藏起来的a b(1<=a,b<=1e30) 每次可 printf("? %d %d\n",c,d); 表示询问 a^c 与 b^d 的相对大小 最多可询问62次 然后 scanf("%d",&ans); 读入返回的答案 ans=1 说明 a^c > b^d ans=0 说明 a^c = b^d ans=-1 说明 a^c < b^d 当通过询问确定了a b就 printf("! %d %d\n&quo…
题意:有两数a,b,每次你可以给定c,d询问a xor c和b xor d的大小关系,最多询问62次($a,b<=2^{30}$),问a和b 考虑从高位往低位做,正在做第i位,已经知道了a和b的前i-1位 这样的话,只要让a.c,b.d的前i-1位相同,就和前i-1位没关系了 考虑在第i位上abcd的情况对应的回答(后面的位数都给0),其中~表示与第i位后面的相关 那我可以分别用01 10询问两次,如果是先大后小或是先小后大,就能判断出是00或者11 但如果前后两次相同,那就有可能是01或者10…
D. Ehab and another another xor problem 题目链接:https://codeforces.com/contest/1088/problem/D Description: This is an interactive problem! Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b)(a,b). Laggy can ask a pair of integers (c,d)(c,d) a…
Ehab and a component choosing problem 如果有多个连接件那么这几个连接件一定是一样大的, 所以我们先找到值最大的连通块这个肯定是分数的答案. dp[ i ]表示对于 i 这棵子树包含 i 这个点的连通块的最大值, 就能求出答案, 然后知道最大值之后再就能求出几个连接件. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make…