2017 ccpc哈尔滨 A题 Palindrome】的更多相关文章

2017 ccpc哈尔滨 A题 Palindrome 题意: 给一个串\(T\),计算存在多少子串S满足\(S[i]=S[2n−i]=S[2n+i−2](1≤i≤n)\) 思路: 很明显这里的回文串长度为奇数,所以用\(manacher\)处理时不需要添加间隔字符 所以这里的\(Len[i]\)表示的就是以\(i\)为中心的回文串向左右最远能延伸的长度 那么\(S[i]=S[2n−i]=S[2n+i−2](1≤i≤n)\)就等价于 找到一对$(i,j), 满足i - Len[i] + 1 <=…
题目链接  2017 CCPC Harbin Problem K 题意  给定若干物品,每个物品可以覆盖一个区间.现在要覆盖区间$[1, t]$. 求选出来的物品的$\frac{∑a_{i}}{∑b_{i}}$的最小值. 首先二分答案,那么每个物品的权值就变成了$x * b_{i} - a_{i}$ 在判断的时候先把那些权值为正的物品全部选出来, 然后记录一下从$1$开始可以覆盖到的最右端点的位置. 接下来开始DP,按照区间的端点升序排序(左端点第一关键字,右端点第二关键字) 问题转化为能否用剩…
题目链接  2017 CCPC Hangzhou  Problem E 题意  给定一棵树,每个点有一个权值,现在我们可以选一些连通的点,并且把这点选出来的点的权值相加,得到一个和. 求$[1, m]$里面哪些值可以被表示成选出来的点的权值和.用$01$序列的方式输出. 重现赛赛场上的我英勇无畏,大胆做$3000$次FFT合并两个bitset表示的答案. 然后TLE到结束(活该) 其实这个题确实要用bitset,关键是能不能把合并两个bitset转化成合并一个数和一个bitset. 考虑点分治.…
题目链接  2017 CCPC Hangzhou Problem H 思路:对树进行分块.把第一棵树分成$\sqrt{n}$块,第二棵树也分成$\sqrt{n}$块.    分块的时候满足每个块是一个连通块,那么每个块就有一个共同的祖先. 把询问按照第一个点被第一棵树的哪个祖先管辖和第二个点被第二棵树的哪个祖先管辖,分成$n$类. 每一类询问一起处理,处理完后用可撤销并查集恢复到之前的状态. 每一类询问之间依次转移,每次转移,移动次数不会超过$\sqrt{n}$次. 最后总时间复杂度$O(n^{…
题目链接  2017 CCPC Harbin Problem A Problem B Problem D Problem F Problem L 考虑二分答案. 设当前待验证的答案为x 我们可以把第二个条件转化为在子树中最多有几个点是黑色的. 那么我们可以根据这些条件求出以每个点为根的子树的黑点数范围,做一次dfs. 最后看看根结点的范围是否包含x即可. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for…
The 2017 China Collegiate Programming Contest Qinhuangdao Site is coming! There will be  teams participating in the contest, and the contest will be held on a huge round table with  seats numbered from 1 to  in clockwise order around it. The -th team…
PUBG is a multiplayer online battle royale video game. In the game, up to one hundred players parachute onto an island and scavenge for weapons and equipment to kill others while avoiding getting killed themselves. BaoBao is a big fan of the game, bu…
BaoBao is trapped in a one-dimensional maze consisting of  grids arranged in a row! The grids are numbered from 1 to  from left to right, and the -th grid is marked with a character , where  is either 'L' or 'R'. Starting from the -th grid, BaoBao wi…
BaoBao has just found a string  of length  consisting of 'C' and 'P' in his pocket. As a big fan of the China Collegiate Programming Contest, BaoBao thinks a substring  of  is "good", if and only if  'C', and  'P', where  denotes the -th charact…
Geometry Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1091    Accepted Submission(s): 208Special Judge Problem Description Alice is interesting in computation geometry problem recen…