字符串处理——模拟与暴力
Alex_McAvoy
想要成为渔夫的猎手
展开
-
字符串处理 —— 模拟与暴力
【概述】在某些题目中,需要对字符串进行处理,不需要很复杂的算法,只需要按照题意进行模拟或暴力枚举即可得出答案。【例题】1.简单模拟Minimum Ternary String(CF-1009B):点击这里 Delete from the Left(CF-1005B):点击这里 Alphabetic Removals(CF-999C):点击这里 潜伏者(洛谷-P1071):点击...原创 2019-03-12 15:04:01 · 724 阅读 · 0 评论 -
Delete from the Left(CF-1005B)
Problem DescriptionYou are given two strings s and t. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the str...原创 2018-08-05 20:21:56 · 445 阅读 · 0 评论 -
一次元リバーシ / 1D Reversi(AtCoder-2146)
Problem DescriptionTwo foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each p...原创 2019-05-22 21:33:33 · 529 阅读 · 0 评论 -
An Ordinary Game(AtCoder-2153)
Problem DescriptionThere is a string s of length 3 or greater. No two neighboring characters in s are equal.Takahashi and Aoki will play a game against each other. The two players alternately per...原创 2019-05-23 15:13:06 · 330 阅读 · 0 评论 -
白昼夢 / Daydream(AtCoder-2158)
Problem DescriptionYou are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S=T by performing the following ...原创 2019-05-23 15:43:45 · 397 阅读 · 0 评论 -
怪文書 / Dubious Document(AtCoder-2393)
Problem DescriptionSnuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.He will receive a headline which contains one of the st...原创 2019-06-06 17:12:35 · 295 阅读 · 0 评论 -
Wide Flip(AtCoder-3732)
Problem DescriptionYou are given a string S consisting of 0 and 1. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following op...原创 2019-07-12 19:45:28 · 314 阅读 · 0 评论 -
Two Strings(CF-223B)
Problem DescriptionA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|).You've go...原创 2019-03-25 18:51:29 · 256 阅读 · 0 评论 -
RGB Substring (easy version) (CF-1196D1)
Problem DescriptionThe only difference between easy and hard versions is the size of the input.You are given a string ss consisting of nn characters, each character is 'R', 'G' or 'B'.You are a...原创 2019-07-25 16:25:23 · 384 阅读 · 0 评论 -
Eva and Euro coins(Gym-101981E)
Problem DescriptionEva is fond of collecting coins. Whenever she visits a different country, she always picks up as many localcoins as she can. As you know, Eva also likes to go trips to Europe; t...原创 2019-08-20 18:40:19 · 794 阅读 · 0 评论 -
Substrings Sort(CF-988B)
Problem DescriptionYou are given n strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed...原创 2018-08-07 17:29:37 · 346 阅读 · 0 评论 -
String(HDU-6586)
Problem DescriptionTom has a string containing only lowercase letters. He wants to choose a subsequence of the string whose length iskand lexicographical order is the smallest. It's simple and he...原创 2019-09-23 20:20:12 · 306 阅读 · 0 评论 -
Anigram单词(51Nod-1095)
题目一个单词a如果通过交换单词中字母的顺序可以得到另外的单词b,那么定义b是a的Anigram,例如单词army和mary互为Anigram。另:相同的2个单词不算Anigram。现在给定一个字典,输入Q个单词,从给出的字典中找出这些单词的Anigram。输入第1行:1个数N,表示字典中单词的数量。(1 <= N <= 10000)第2 - N + 1行,字典中的单词,...原创 2019-04-17 18:14:47 · 460 阅读 · 0 评论 -
Best Cow Line(POJ-3617)
Problem DescriptionFJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the jud...原创 2018-06-09 22:37:15 · 266 阅读 · 0 评论 -
Stages(CF-1011A)
Problem DescriptionNatasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way,...原创 2018-08-15 14:54:52 · 311 阅读 · 0 评论 -
アンバランス / Unbalanced(AtCoder-2020)
Problem DescriptionGiven a stringt, we will call itunbalancedif and only if the length oftis at least2, and more than half of the letters intare the same. For example, bothvoodooandmelee...原创 2019-05-19 15:27:13 · 2987 阅读 · 0 评论 -
处女座的比赛
【题目描述】经过了训练、资金等多方面的准备,处女座终于可以去比赛了!比赛采用codeforces赛制,也就意味着可以插人。现在有一道字符串的题目,处女座在room里看到一个用hash做的,于是决定把它hack掉。这个人的核心代码如下:const int mod=9983;mul[0]=p;mul[1]=q;mul[2]=r;for (int i=0;i<26;i++) ...原创 2019-01-30 12:01:27 · 470 阅读 · 0 评论 -
Minimum Ternary String(CF-1009B)
Problem DescriptionYou are given a ternary string (it is a string which consists only of characters '0', '1' and '2').You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. repl...原创 2018-08-23 20:16:00 · 302 阅读 · 0 评论 -
Two Strings Swaps(CF-1006D)
Problem DescriptionYou are given two strings a and b consisting of lowercase English letters, both of length n. The characters of both strings have indices from 1 to n, inclusive.You are allowed ...转载 2018-08-06 12:02:29 · 487 阅读 · 0 评论 -
潜伏者(洛谷-P1071)
题目描述R 国和 S 国正陷入战火之中,双方都互派间谍,潜入对方内部,伺机行动。历尽艰险后,潜伏于 S 国的 R 国间谍小 C 终于摸清了 S 国军用密码的编码规则:1. S 国军方内部欲发送的原信息经过加密后在网络上发送,原信息的内容与加密后所得的内容均由大写字母‘A’-‘Z’构成(无空格等其他字符)。2. S 国对于每个字母规定了对应的“密字”。加密的过程就是将原信息中的所有字母...原创 2018-04-11 23:39:43 · 464 阅读 · 0 评论 -
处女座与复读机
【题目描述】一天,处女座在牛客算法群里发了一句“我好强啊”,引起无数的复读,可是处女座发现复读之后变成了“处女座好强啊”。处女座经过调查发现群里的复读机都是失真的复读机,会固定的产生两个错误。一个错误可以是下面的形式之一:1.将任意一个小写字母替换成另外一个小写字母2.在任意位置添加一个小写字母3.删除任意一个字母处女座现在在群里发了一句话,他收到了一个回应,他想知道这是不是...原创 2019-01-24 21:56:51 · 303 阅读 · 0 评论 -
字符串的展开(洛谷-P1098)
题目描述在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输出时,用连续递增的字母或数字串替代其中的减号,即,将上面两个子串分别输出为“defgh”和“45678”。在本题中,我们通过增加一些参数的设置,使字符串的展开更为灵活。具体约定如下:(1) 遇到下面的情况需要做字符串的...原创 2018-04-03 23:26:18 · 861 阅读 · 0 评论 -
Alphabetic Removals(CF-999C)
Problem DescriptionYou are given a string sconsisting of n lowercase Latin letters. Polycarp wants to remove exactly kcharacters (k≤n) from the string s. Polycarp uses the following algorithm kt...原创 2018-08-07 18:28:20 · 397 阅读 · 0 评论 -
Hexadecimal View(HDU-4054)
Problem DescriptionHexadecimal is very important and useful for computer programmers. You are requested to provide a hexadecimal view for given data. The hexadecimal view is made up of one or more ...原创 2019-03-16 21:29:38 · 281 阅读 · 0 评论 -
Segment Occurrences(CF-1016B)
Problem DescriptionYou are given two strings ss and tt, both consisting only of lowercase Latin letters.The substring s[l..r] is the string which is obtained by taking characters sl,sl+1,…,sr wit...原创 2018-08-13 16:50:16 · 363 阅读 · 0 评论 -
LCP Array(HDU-5635)
Problem DescriptionPeter has a string s=s1s2...sn, let suffi=sisi+1...sn...sn be the suffix start with ii-th character of ss. Peter knows the lcp (longest common prefix) of each two adjacent suffix...原创 2019-01-18 20:08:20 · 280 阅读 · 0 评论 -
Abbreviation(ZOJ-4105)
Problem DescriptionIn the Test of English as a Foreign Language (TOEFL), the listening part is very important but also very hard for most students since it is usually quite hard for them to remembe...原创 2019-04-27 19:16:41 · 558 阅读 · 0 评论 -
Registration system(NYOJ-991)
Problem DescriptionA new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ...原创 2019-02-11 20:05:45 · 242 阅读 · 0 评论