Codeforces 932.A Palindromic Supersequence】的更多相关文章

A. Palindromic Supersequence time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a string A. Find a string B, where B is a palindrome and A is a subsequence of B. A subsequence o…
占坑,明天写,想把D补出来一起写.2/20/2018 11:17:00 PM ----------------------------------------------------------我是分割线------------------------------------------------------- 我来了,本来打算D题写到一起的,但是有新的东西要写,D就单独写一篇,这里写A,B,C: 开启智障模式:(看我咸鱼突刺的厉害( • ̀ω•́ )✧)   2/21/2018 10:46:…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 字符串倒着加到原串右边就好 [代码] #include <bits/stdc++.h> using namespace std; int main(){ #ifdef LOCAL_DEFINE freopen("rush_in.txt", "r", stdin); #endif ios::sync_with_stdio(0),cin.tie(0); string s; cin >&…
http://codeforces.com/contest/932/problem/E 题意:   可以看做 有n种小球,每种小球有无限个,先从中选出x种,再在这x种小球中任选k个小球的方案数 选出的x种不一样,任选k个球的顺序不一样 均视做不同的方案 f[i][j] 表示选了i个小球,来自j种的方案数 那么答案就是 考虑选的第i个球是否是选过的一种, f[i][j]=f[i-1][j]*j+f[i-1][j-1]*(n-(j-1)) #include<cstdio> #include<…
F. Escape Through Leaf time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given a tree with n nodes (numbered from 1 to n) rooted at node 1. Also, each node has two values associated…
E. Team Work time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people fo…
D. Tree time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output You are given a node of the tree with index 1 and with weight 0. Let cnt be the number of nodes in the tree at any instant (initiall…
[题意]给你一个串,让你求出k阶回文子串有多少个.k从1到n.k阶子串的定义是:子串本身是回文串,而且它的左半部分也是回文串. [算法]区间DP [题解]涉及回文问题的区间DP都可以用类似的写法,就是h[i][j]表示i~j是否回文,然后就可以O(1)判断回文了. f[i][j]=k表示该字符串是k-th字符串,因为首先要求回文,既然回文那么左半边和右半边就肯定一样了. #include<cstdio> #include<algorithm> #include<cstring…
C. Permutation Cycle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: Let g(i) be the minimum positive…
B. Recursive Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let us define two functions f and g on positive integer numbers. You need to process Q queries. In each query, you will…
C. Permutation Cycle   time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: Let g(i) be the minimum positi…
B. Recursive Queries   time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let us define two functions f and g on positive integer numbers. You need to process Q queries. In each query, you wi…
题目链接 题意 : 其实就是要求 分析 : 先暴力将次方通过第二类斯特林数转化成下降幂 ( 套路?) 然后再一步步化简.使得最外层和 N 有关的 ∑ 划掉 这里有个技巧就是 将组合数的表达式放到一边.然后通过组合意义来化简 然后就可以 O( k ^ 2 ) 算出答案了 另外化到后面其实有种产生 这里可以用另外一种方式化简 考虑其组合意义 相当于先从 n 个数中挑出 i 个数.然后再从 i 个数中取 j 个进行排列 其他数可选可不选 具体可以看 Click here #include<bits/s…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vect…
2018-02-19 A. Palindromic Supersequence time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a string A. Find a string B, where B is a palindrome and A is a subsequence of B. A su…
A - Palindromic Supersequence /* 题目大意:给出一个串,构造一个包含该串的回文串 */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int N=10010; char s[N]; int main(){ scanf("%s",s); int n=strlen(s); for(int i=n-1;…
靠这把上了蓝 A. Palindromic Supersequence time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a string A. Find a string B, where B is a palindrome and A is a subsequence of B. A subseq…
Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th number is the total number of non-empty substrings of s which are k-palindromes. A string is 1-palindrome if and only if it reads the same backward as f…
任意门:http://codeforces.com/contest/1118/problem/C C. Palindromic Matrix time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let's call some square matrix with integer values in its cells palind…
证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 (Div. 2) 题意: 定义 k 回文串满足: 1. 左右子串相等 2. 左右子串为k-1回文串 1 回文串 就是回文串 问你字符串s的子串的每阶回文子串的数目 分析: 研究一下可以发现 k 回文串的要求等价于 1. 本身是回文串 2. 左右子串是k-1回文串 然后可以dp了,还有一个结论是: 若…
本来准备好好打一场的,然而无奈腹痛只能带星号参加 (我才不是怕被打爆呢!) PROBLEM C - Star sky 题 OvO http://codeforces.com/contest/835/problem/C 835C 解 由于题目中给的c很小,可以对应每种亮度分别保存(c+1)个矩阵 然后初始化一下求前缀矩阵 每次询问就可以O(c)求出答案 (Accepted) #include <iostream> #include <cstring> #include <cst…
Palindromic characteristics of string s with length |s| is a sequence of |s|integers, where k-th number is the total number of non-empty substrings of s which are k-palindromes. A string is 1-palindrome if and only if it reads the same backward as fo…
https://codeforces.com/contest/1118/problem/C 在查找元素的时候,必须按4,2,1的顺序进行.因为,如果先找1,可能就把原来的4拆散了,然后再找4,就找不到了 #include<bits/stdc++.h> using namespace std; ][]; int main(){ int n; cin>>n; map<int,int> mp; int t; ;i<n*n;i++){ cin>>t; mp[t…
题目链接:http://codeforces.com/problemset/problem/883/H Time limit: 3000 ms Memory limit: 262144 kB Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits. He wants to rearrange the symbols in s and cut it into th…
题目链接: https://codeforces.com/contest/835/problem/D 题意: 一个回文串是\(1\)-回文的,如果一个回文串的左半部分和右半部分一样且都是\(k\)-回文串(右半部分是指长度为该串长度除以二下取整的后缀),则该串为\((k+1)\)回文串,满足该串是\(k\)回文串的最大\(k\)称作该串的回文级别.给定一个串\(s\), 对于每一个\(k=1,2,...,n\)求出该串中有多少个位置不同的\(k\)-回文串.\(n\le 5\times 10^6…
[Link]:http://codeforces.com/contest/835/problem/D [Description] 给你一个字符串; 让你在其中找到1..k阶的回文子串; 并统计它们的数量 如果一个字符串是一个回文串,则它可以是1阶子串; k阶字符串,要求它的左边和右边都是k-1阶子串; [Solution] bo[i][j]表示i..j这一段是否为回文; 可以用O(n2)的复杂度处理出整个bo数组; 然后O(n2)枚举每一段区间; 算出这个区间的字符串最大可以是一个几阶字符串记为…
题目链接 http://codeforces.com/contest/1205/problem/C 题解 菜鸡永远做着变巨的梦 然而依然连div1BC题都不会做 要是那天去打cf怕是又要1题滚粗了.... 首先第一步显然是对于所有\(i+j\)为偶数的点(下称"偶点")求出\(a_{i,j}\)的值,对于所有\(i+j\)为奇数的点(下称"奇点")求出它们之间的相对关系.也就相当于强行令\(a_{1,2}=x\)之后求出所有奇点是\(x\)还是\(x\ \text{…
题目链接:https://codeforces.com/contest/1366/problem/C 题意 有一个 $n \times m$ 的 $01$迷宫,要使从 $(1,1)$ 到 $(n,m)$ 的所有路径均为回文串,至少要变换多少字符. 题解一 用 $bfs$ 得到回文串每个位置可能的 $01$ 个数,对称位置变换 $01$ 总个数中的较少值即可. 代码 #include <bits/stdc++.h> using namespace std; const int dir[4][2]…
题目链接:Palindromic Paths 题意: 给你一个n行m列的矩阵,这个矩阵被0或者1所填充,你需要从点(1,1)走到点(n,m).这个时候会有很多路径,每一条路径对应一个01串,你可以改变这个矩阵中某些位置的值,你需要保证改变之后每一条路径串都是回文串. 最后输出你最少需要改变多少位置 题解: 因为你要保证每一条路径都是回文路径,那么如下面这组样例: 3 5 1 0 1 0 0 1 1 1 1 0 0 0 1 0 0 起点位置(1,1)的值是1但是终点位置(n,m)的值是0,但是在一…
本题是个简单的区间dp 最近都没时间做题了,被我妈强制喊回去,然后颓废了10天(回家也没发控制住自己= = 我的锅),计划都打乱了,本来还报名了百度之星,然后没时间参加 #include<cmath> #include<map> #include<iostream> #include<cstring> #include<cstdio> #include<set> #include<vector> #include<q…