Nikita and string [思维-暴力] ACM】的更多相关文章

codeforces Nikita and string time limit per test   2 seconds memory limit per test   256 megabytes One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 stri…
B. Nikita and string time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beauti…
题目链接:http://codeforces.com/contest/877/problem/B Nikita and string time limit per test2 seconds memory limit per test256 megabytes Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of t…
Crazy Binary String 思维 题意 给出01串,给出定义:一个串里面0和1的个数相同,求 满足定义的最长子序列和子串 分析 子序列好求,就是0 1个数,字串需要思考一下.实在没有思路可以看看数组范围(n<=1e5),很像nlogn或者n的算法,这个时候就要考虑一下二分和前缀和优化,二分感觉⑧太行,这个时候研究一下前缀和的性质,发现0 为-1,1为1的时候,前缀和相同的两个位置中间恰好可以构成一个满足定义的串,所以这题就解决了.没有思路的时候多发散一下思维,从多角度思考一下问题.…
B. Game with string 思维问题转化 题意 有一个字符串 每次可以删去连续的两个同样的字符,两个人轮流删,问最后谁能赢 思路 初看有点蒙蔽,仔细看看样例就会发现其实就是一个括号匹配问题,直接搞一个栈看有多少对合法的括号即可 #include<bits/stdc++.h> #define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;i++) #define MS(arr,arr_value) memset(arr,arr_…
http://www.ifrog.cc/acm/problem/1054 问删除一个字符后的最小循环节是多少. 比赛的时候想不出,不知道怎么暴力. 赛后看了别人代码才晓得.唉,还以为自己字符串还不错,但是变了一点点就不懂了. 1.可以暴力枚举循环节长度i,必要条件是(lenstr - 1) % i == 0.这是必须的,因为必须是倍数,关于约数的个数:(不大) http://vfleaking.blog.163.com/blog/static/174807634201341913040467/…
题意: 询问一共有有多少个CCPC,每个得1分,可以自己在任意位置添加字母,第i次添加需要耗费i-1分 思路: 既然每次添加需要耗分,添加第二个字母,相当于没有添加,所以只需要添加一次就好 先计算出原始字符串中的CCPC,在不破坏CCPC的前提下,添加字母即可 代码: #include<iostream> #include<cstdio> using namespace std; const int maxn = 2e5+10; int flag[maxn]; char str[m…
传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 1007    Accepted Submission(s): 422 Description Problem DescriptionYoung theoretical computer scientist Fxx get a string which…
Mine Number Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Every one once played the game called Mine Sweeping, here I change the rule. You are given an n*m map, every element is a '*' representing a mine, or a '.' representing any other…
A - String LD Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 4423 Description Stringld(left delete) is a function that gets a string and deletes its leftmost character (for instance Stringld(``ac…