题目链接:282E Sausage Maximization 题目大意:给定一个序列A.要求从中选取一个前缀,一个后缀,能够为空,当时不能重叠.亦或和最大. 解题思路:预处理出前缀后缀亦或和,然后在字典树中维护.每次加入并查询.过程中维护ans. #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; typedef lon…
练习赛的时候这道题死活超时....想到了高位确定后..低位不能对高位产生影响..并且高位要尽可能的为1..就是想不出比较好的方法了实现... 围观大神博客..http://www.cnblogs.com/zhj5chengfeng/archive/2013/05/14/3077621.html 思路很清晰了..没什么补充的..自己的思维还是不够啊...大神几句话点拨...豁然开朗... Program: #include<iostream> #include<string.h> #…
题目链接:http://codeforces.com/problemset/problem/282/E E. Sausage Maximization time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Bitlandians are quite weird people. They have their own prob…
题目链接 给n个数, 让你找出一个前缀和一个后缀, 它们异或完以后最大, 前缀和后缀都是异或得来的, 可以为空, 为空时按0算.前缀后缀不可覆盖. 这题好神, 竟然是Trie树... 首先将所有数的异或算出来作为初始的后缀, 初始前缀为0. 然后往字典树里插入前缀, 在对后缀进行查找, 查找时, 从高位往低位找, 如果后缀的第i位为0, 那么就找字典树里这一位有没有1, 有1就往1的那一条路找,没有就只能往0那一条路找. 具体看代码. #include <iostream> #include…
题目链接:http://codeforces.com/problemset/problem/665/E (http://www.fjutacm.com/Problem.jsp?pid=2255) 题意:找出有多少个连续的区间[l,r](1  ≤  l  ≤  r  ≤  n),该区间中所有的数的异或值大于等于k: 思路:首先,如果是单看题目的话,会发现暴力的话复杂度是O(n^3),但是我们先预处理异或前缀和,然后你会发现[l,r]区间的异或和等于s[l-1]^s[r],这样就可以O(n^2)的求…
As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires. Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and…
题目链接:Perfect Security 题意:给出N个数代表密码,再给出N个数代表key.现在要将key组排序,使key组和密码组的亦或所形成的组字典序最小. 题解:要使密码组里面每个数都找到能使其亦或和最小的数可以将key建成一棵字典树(这里建树方式很关键,可以每个数都从2^31开始建树,这样可以使我们在遍历树查询更加方便).之后再遍历密码组每次在字典树里面找到一个能使它亦或和最小的数,再将这个数从字典树中删掉...  字典树太久不写,很多东西都忘记了! #include<bits/std…
传送门 D. Good Substrings time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad. A s…
题目链接:http://codeforces.com/problemset/problem/706/D 题意:q次操作,可以向多重集中增添,删除,询问异或最大值. 思路:转化为二进制用字典树存储,数字从高位开始,并全部固定位30位. #include<bits/stdc++.h> using namespace std; const int N=2e5 + 5; int now = 1 ,Trie[N<<5][2] ,num[N<<5]; void Insert(int…
E. Ann and Half-Palindrome Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/problem/E Description Tomorrow Ann takes the hardest exam of programming where she should get an excellent mark. On the last theoretical class t…