Gym 100570E : Palindrome Query】的更多相关文章

De Prezer loves palindrome strings. A string s1s2...sn is palindrome if and only if it is equal to its reverse. De Prezer also loves queries. You are given string s of length n and m queries. There are 3 types of queries : 1. 1px : Modify sp = x wher…
E. Palindrome QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100570/problem/E Description De Prezer loves palindrome strings. A string s1s2...sn is palindrome if and only if it is equal to its reverse. De Prezer also love…
题意:给定字符串char[],以及Q个操作,操作有三种: 1:pos,chr:把pos位置的字符改为chr 2:pos:问以pos为中心的回文串长度为多长. 3:pos:问以pos,pos+1为中心的回文串长度为多长. 思路:用hash表示一段字符串或者连续子串.我们用BIT记录hash前缀和,那么也可以用BIT修改前缀和.然后blabla,乱搞就行了. 当然为了保险,最好用双hash. (此题暴力也可以过! 暴力代码:3962ms #include<bits/stdc++.h> #defin…
题意:询问单源最短路径,每条边有一个颜色,要求路径上相邻边的颜色不能相同,无重边且边权为正. 题解:因为路径的合法性和边的颜色有关, 所以在做spfa的时候,把边丢到队列中去,松弛的时候注意判断一下颜色,d数组表示到这条边的出点v的距离. 期望复杂度是O(km),k是边入队次数,m是边数.最后根据边来松弛顶点,O(m),总复杂度是O(km+m). 一开始想的Dijkstra(看到边权为正..),存点和之前边的颜色每次更新的时候判断来的那个点的颜色和当前边的颜色是否一样,WA了,很快我就意识到,入…
题目链接:https://vjudge.net/contest/155789#problem/E 题解: 由于是回文串,所以可以先将在对称位置的字符放在同一个集合(如果期间有两个非‘?’,且不相等,则退出操作.并跳过之后的某些步骤.注意输入不能跳过).然后再接收输入的限制条件,进行并查集.有两种并查集的方式,而两种方式的共同点都是根节点存放这个集合的字符值. 方法一(根据字符的情况选择根节点) 1.如果两个结点的祖先的字符相等,则随便一个结点的祖先做根节点: 2.如果一个的祖先是‘?’,一个的祖…
\(\mathcal{Description}\)   Link.   给定一棵含 \(n\) 个结点的树,结点 \(1\) 为根,点 \(u\) 初始有点权 \(a_u=0\),维护 \(q\) 次操作: 给定 \(u\),将 \(u\) 子树内的点权加 \(1\): 给定 \(u,v\),将 \(u,v\) 简单路径上的点权加 \(1\).   每次操作后,求出树最靠近结点 \(1\) 的带权重心.   \(n,q\le10^5\). \(\mathcal{Solution}\)   记点权…
A. Cursed QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100571/problem/A Description De Prezer loves movies and series. He has watched the Troy for like 100 times and also he is a big fan of Supernatural series.So, he di…
H. Special Palindrome time limit per test:1 second memory limit per test:64 megabytes input:standard input output:standard output A sequence of positive and non-zero integers called palindromic if it can be read the same forward and backward, for exa…
C. Palindrome Again !! time limit per test:1 second memory limit per test:64 megabytes input:standard input output:standard output Given string with N characters, your task is to transform it to a palindrome string. It's not as easy as you may think…
http://codeforces.com/gym/100952/problem/H H. Special Palindrome time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output A sequence of positive and non-zero integers called palindromic if it can be…