hiho一下:Beautiful String】的更多相关文章

hiho一下:Beautiful String 记不清这是 hiho一下第几周的题目了,题目不难,不过对于练习编程,训练思维很有帮助.况且当时笔者处于学习算法的早期, 所以也希望刚接触算法的同学能多去练习一下. 题目介绍 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 We say a string is beautiful if it has the equal amount of 3 or more continuous letters (in increasi…
链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa&…
CF1328B K-th Beautiful String,然而CF今天却上不去了,这是洛谷的链接 题意 一个长度为\(n\)的字符串,有2个\(\texttt{b}\)和\(n-2\)个\(\texttt{a}\) 按字典序排序后,问你第\(k\)个是啥 \(n\leq 10^5\) 由于我们相信CF从来不卡常,所以这实际是个\(O(n)\)找规律 看题目里的例子: aaabb aabab aabba abaab ababa abbaa baaab baaba babaa bbaaa 可以发现…
题目链接:http://hihocoder.com/problemset/problem/1061 题目意思:给出一个不超过10MB长度的字符串,判断是否里面含有一个beautiful strings的子串:连续递增且数量相等的字母. 照着题目分析翻译的代码... 分析得很到位呢,大赞 ^_^ http://hihocoder.com/discuss/question/2083 hiho的题目其实挺好的,有专题,有分析,有代码 & 思路参考... 想想出来工作那么久,浮躁的心啊,一个多快两个月没…
题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母,问能否字符串中所有相邻字母都不同. 题解 除非一开始字符串就不合法,否则一定可以构造出合法的字符串,因为共有三个字母可选,而替换时最多需要判断前后两个位置. 代码 #include <bits/stdc++.h> using namespace std; void solve() { strin…
问题 https://vjudge.net/problem/HackerRank-beautiful-string 给一个字符串S,可以任意取走S中的两个字符从而得到另外一个字符串P,求有多少种不同的P \(\left|S\right|\le10^6\) 题解 想到组合数 将连续的相同的字符分为1组,如字符串“aaabbbbaccca” 则可以选两组中的两个字母或一组中的两个字母 计算出连续的组数设为x计算出长度大于等于2的组数设为y\[ans = \left( \begin{array}{l}…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered…
L - Ferris Wheel String Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 43000/43000KB (Java/Others) Submit Status Have you ever been to London? Our Master Qiu will tell you how amazing in London and how funny a Ferris Wheel String is. One day…
Pasha and String Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 525B Description Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. Th…
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…
Codeforces Round #297 (Div. 2)B. Pasha and String Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/B Description Pasha got a very beautiful string s for his birthday, the string consists o…
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…
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string. Pasha didn't like his present…
因为4月初要参加微软的online.所以今天把微软的面试题拿出来做了,自己解答了题目.下面附上我的解答代码. -----------16年9月校招:  第一道题:Farthest Point(最远的整数点) 题目: #1237 : Farthest Point 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 Given a circle on a two-dimentional plane. Output the integral point in or on the…
题目大意 题目连接:beautiful string     写代码之前,考虑清楚流程,以及需要维护的变量.... 实现 #include<iostream> #include<stdio.h> #include<string.h> #include<stack> #include<vector> #include<unordered_set> #include<unordered_map> using namespace…
A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A Description Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the…
A. Treasure time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s writte…
正反两遍扩展KMP,维护公共长度为L时.出如今最左边和最右边的位置. . .. 然后枚举推断... E. Martian Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output During the study of the Martians Petya clearly understood that the Mart…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
google了很多次才发现在国外网站上有提示如何比较中文,原文地址:http://www.webdeveloper.com/forum/showthread.php?t=9365 前提:使用Unicode 编码,如果其他GBK此方法应该就不行! 定义和用法 用本地特定的顺序来比较两个字符串. stringObject.localeCompare(target) target:要以本地特定的顺序与 stringObject 进行比较的字符串 测试1: var str="北京"; var…
Pasha and String CodeForces - 525B Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given str…
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…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
A. Treasure time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s writte…
负二进制转换 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Problem Description QAQ学长对于现在大家普遍学习的C语言.Java语言等等很是不屑,他认为二进制指令才是最优美的语言;苦苦思考哲学的QAQ学长已经不满足正二进制了,他现在研究的是负二进制,他给你一串负二进制表示的编码,希望你告诉他这串负二进制表示的十进制数是多少. Input Output Sampl…
B. Pasha and String time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the…
Martian Strings Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 149E64-bit integer IO format: %I64d      Java class name: (Any)   During the study of the Martians Petya clearly understood that the Mar…
A. Beautiful String (暴力) 题目链接 题目大意: 给定一个字符串,只有 \(?a\ b\ c\ ?\) ,问是否存在一种将所有的 \(?\) 替换成 \(a\ b\ c\) ,使得任意相邻的字符不同的方法. 大致思路: 其实可以发现问号都可以通过枚举使得其合法,若出现不合法必然除去问好已经不合法,暴力枚举即可. 代码: 点击展开代码 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; char…
B. Nikita and string 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 strings (possibly empty) without changing the order of the letters, where the 1-st…