传送门 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/271/D 题目原文: 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…
题目链接: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…
题目链接:282E Sausage Maximization 题目大意:给定一个序列A.要求从中选取一个前缀,一个后缀,能够为空,当时不能重叠.亦或和最大. 解题思路:预处理出前缀后缀亦或和,然后在字典树中维护.每次加入并查询.过程中维护ans. #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; typedef lon…
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…
E. Ann and Half-Palindrome time limit per test 1.5 seconds memory limit per test 512 megabytes input standard input output standard output Tomorrow Ann takes the hardest exam of programming where she should get an excellent mark. On the last theoreti…
题目链接: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…
题目链接: http://codeforces.com/contest/706/problem/D 题目大意: 三种操作,1.添加一个数,2.删除一个数,3.查询现有数中与x异或最大值.(可重复) 题目思路: [字典树][贪心] 维护一个字典树,左0右1.查询时从上往下走. // //by coolxxx // #include<iostream> #include<algorithm> #include<string> #include<iomanip>…