CodeForces 805B 3-palindrome】的更多相关文章

In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick. He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c'…
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and &qu…
C. Palindrome Transformation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningl…
  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 th…
[题目链接]:http://codeforces.com/contest/805/problem/B [题意] 让你生成一个只包含a,b,c的字符串; 要求c出现的次数最少,且任意一个 长度为3的子串都不为回文. [题解] 随便生成一个 abb 然后对于第i位 只要不和第i-2位一样就可以了; 这样就可以只用a和b构成这个字符串了,不包括c,肯定是最优的了. [Number Of WA] 0 [完整代码] #include <bits/stdc++.h> using namespace std…
构造. $bbaabbaabbaa......$输出前$n$个即可,这样不需要用到$c$,而且任意相邻三个都不会是回文. #include <cstdio> #include <cmath> #include <set> #include <cstring> #include <algorithm> using namespace std; int n; int a[500010]; void init() { int pre = 0; int…
要保证变化次数最少就是出现次数为奇数的相互转化,而且对应字母只改变一次.保证字典序小就是字典序大的字母变成字典序小的字母. 长度n为偶数时候,次数为奇数的有偶数个,按照上面说的搞就好了. n为奇数时,要考虑最后中间那个字母.交换法可以证明,其实是贪心最后没有转化掉的字母. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; char s[LEN]; ]; //#define LOCAL int main()…
[链接] 我是链接,点我呀:) [题意] 光标一开始在p的位置 你可以用上下左右四个键位移动光标(左右)或者更改光标所在的字符(上下增加或减少ascill码) 问你最少要操作多少次才能使得字符串变成回文 [题解] 首先把字符串分成两个部分 1..n/2 和 n/2+1..n这两个部分 (如果n是奇数比较特殊,右半部分是n/2+2..n) 然后如果p落在右半部分那个区间的话 就让它做一下对称 到左半部分来 因为不可能从右边那个区间移动到左边那个区间的(跨越n到达1),那样做太不划算 这两个区间其实…
根据数据范围,暴力可以解决,对每一个串,找与其互为回文的串,或者判断自身是否为回文串,然后两两将互为回文的串排列在头尾,中间放且只能最多放一个自身为回文串的串,因为题目说每个串都是不同的 #include<bits/stdc++.h> using namespace std; #define lowbit(x) ((x)&(-x)) typedef long long LL; ]; ], self[], s[], chosen[]; void run_case() { int n, m…
每日CF: 411div2 Solved A CodeForces 805A Fake NP Solved B CodeForces 805B 3-palindrome Solved C CodeForces 805C Find Amir Solved D CodeForces 805D Minimum number of steps Attempted E CodeForces 805E Ice cream coloring     F CodeForces 805F Expected dia…