Codeforces 1238D. AB-string】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/797/C 题意: 给你一个非空字符串s,空字符串t和u.有两种操作:(1)把s的首字符取出并添加到t的末尾.(2)把t的尾字符取出并添加到u的末尾. 问你当经过一系列操作后,s和t均为空时,字典序最小的u. 题解: 操作的本质: s为队列,t为栈. 贪心思路: (1)找到s中的最小字符c,不断出队并加入t,直至有一次出队的字符等于c,停止出队. (2)当t的尾字符小于等于s中的最小字符时,优先弹出t的尾…
Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it's now impossible to understand which letter was…
C. Minimal string 题目链接:http://codeforces.com/problemset/problem/797/C time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya recieved a gift of a string s with length up to 105 characters fo…
/** 题目:F. String Compression 链接:http://codeforces.com/problemset/problem/825/F 题意:压缩字符串后求最小长度. 思路: dp[i]表示前i个字符需要的最小次数. dp[i] = min(dp[j]+w(j+1,i)); (0<=j<i); [j+1,i]如果存在循环节(自身不算),那么取最小的循环节x.w = digit((i-j)/x)+x; 否则w = i-j+1; 求一个区间最小循环节: 证明:http://w…
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the string s. Namely, he re…
https://codeforces.com/problemset/problem/1117/E 就用abc表示数字来给每个数编码,编完直接问出移动的结果,反构造就行了,比C和D还简单. #include<bits/stdc++.h> using namespace std; #define ll long long int n; string s1,s2,s3; string t; string q1,q2,q3; ]; ]; void construct(){ ;i<n;i++){…
题目链接:http://codeforces.com/contest/828/problem/C 题解:有点意思的题目,可用优先队列解决一下具体看代码理解.或者用并查集或者用线段树都行. #include <iostream> #include <cstring> #include <queue> #include <vector> #include <cstdio> #include <map> #include <strin…
题目链接:http://codeforces.com/contest/779/problem/D 题意:给你一段操作序列,按顺序依次删掉字符串1中相应位置的字符,问你最多能按顺序删掉多少个字符,使得s2是剩下的字符构成的字符串的子列. 字符串长度为2e5每次查询的时间复杂度为n如果直接暴力那么复杂度就是n*n 如果二分一下答案的话复杂度就是n*logn再加上修改的复杂度总的复杂度是 (n+n)* logn #include <iostream> #include <cstring>…
题目大意 把所有仅包含\(AB\)的字符串按字典序排列,给你一个仅包含\(AB\)的字符串\(S\),然后有\(Q\)个问题,第\(i\)个问题给你\(k_i\),求不是\(S\)的子串中,第\(k_i\)小的是什么.\(T\)组数据 \(T\leqslant5\),\(\sum|S_i|\leqslant2.3\times10^5\),\(Q_i\leqslant10\),\(k_i\leqslant10^9\) 题解 发现,长度为\(l\)的字符串有\(2^l\)个,而\(S\)的长度小于等…
http://www.codeforces.com/problemset/problem/494/B 题意:给出两个串S,T,求有几种将S分成若干个子串,满足T都是这若干个子串的子串. 思路:f[n]代表前n个字符来划分,有多少种划分方式,sum[i]代表1到i的f的和,转移就是:对于i这个位置,可以不选,因此首先 f[i]=f[i-1],然后若是选了i,那一定至少是在有匹配位置的左边开始匹配,假设L为小于i的最右边的匹配位置,则 F[i]+=ΣF[j] (1<=j<=L-1),然后也有可能自…