
数据结构-字符串
文章平均质量分 64
JeraKrs
本人目前就职于百度商业研发部,有需要内推的朋友简历可发我邮箱 jerakrs@qq.com
展开
-
uva 10815 Andy's First Dictionary(字符串处理+sort排序)
Problem B: Andy's First DictionaryTime limit: 3 secondsAndy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of原创 2013-07-25 00:09:10 · 2119 阅读 · 0 评论 -
uva 1339 Ancient Cipher(字符串处理)
Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form t原创 2013-08-18 11:03:57 · 1076 阅读 · 0 评论 -
fzu 1913 Easy Comparison(字符串)
题目链接:fzu 1913 Easy Comparison题目大意:给出一个字符串,计算与它按照字典序排序排列后的字符串有多少个位置不同。解题思路:水体,sort一下,然后遍历一遍就好。#include #include #include using namespace std;const int N = 105;char str[N], tmp原创 2013-12-04 23:28:15 · 1308 阅读 · 0 评论 -
Codeforces 385B Bear and Strings(字符串)
题目连接:Codeforces 385B Bear and Strings题目大意:给出一个字符串,问说该字符串中有多少个子串包含“bear”。解题思路:遍历,每次找到“bear”,就用该串前面个字符数x,以及该串后面的字符数y,ans += (x+1)*(y+1)- 前一个“bear”所在位置的字符串(重复的)#include #include #incl原创 2014-01-30 12:34:50 · 2169 阅读 · 0 评论 -
uva 502 DEL command(字符串处理)
DEL command It is required to find out whether it is possible to delete given files from MS-DOS directory executing the DEL command of MS-DOS operation system only once. There are no n原创 2013-08-11 10:24:35 · 1429 阅读 · 0 评论 -
uva 1314 - Hidden Password(最小表示法)
题目链接:uva 1314 - Hidden Password题目大意:给定一个字符串,求该字符串的最小表示法。解题思路:以两个指针交替移动,逐个比较,直到比较出大小后转移起始位置。#include #include #include using namespace std;const int maxn = 1e5+5;int N;char s[maxn];原创 2014-09-04 21:52:31 · 1209 阅读 · 0 评论 -
zoj 3817 Chinese Knot(hash+暴力)
题目链接:zoj 3817 Chinese Knot题目大意:给出四个字符串,对应着同心结的四条边,现在给定一个目标串,可以从任意节点开始移动,问是否可以匹配目标串。解题思路:用hash将四个字符串的正序和逆序处理出来,然后dfs枚举,每次保留起始位置和移动方向即可。#include #include #include #include using namespace原创 2014-09-10 20:28:07 · 1553 阅读 · 0 评论 -
uva 11988 Broken Keyboard(字符串处理+ STL)
Broken Keyboard (a.k.a. Beiju Text)You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "原创 2013-08-08 00:26:32 · 1272 阅读 · 0 评论 -
uva 475 - Wild Thing(字符串处理)
题目链接:uva 475 - Wild Thing题目大意:给定一个字符串的通配,然后给定一些字符集,问说有哪些字符满足匹配,如果没有一个字符串匹配的话,当前这组数据就任何东西也不输出,包括换行。解题思路:递归去匹配即可,注意∗,∗∗∗这种数据。#include #include #include using namespace std;const int maxn =原创 2014-09-02 19:41:00 · 977 阅读 · 0 评论 -
uva 282 - Rename(字符串)
题目链接:uva 282 - Rename题目大意:给定一个命令行的重命名命令,最多包含一个‘*’,然后给定一些文件名,将该命令转换成若干个执行命令。解题思路:因为最多一个‘*’,所以直接开头结尾匹配掉,再处理中间的即可。#include #include #include #include #include #include using namespace st原创 2014-09-02 19:46:41 · 1115 阅读 · 0 评论 -
uva 257 - Palinwords(哈希字符串)
题目链接:uva 257 - Palinwords题目大意:判定一个字符串是否有两个互相不为子串的回文串为子串。解题思路:枚举长度为3和4的字符串,然后将每个字符串映射成一个hash值。#include #include #include #include using namespace std;const int maxn = 500;char word[m原创 2014-09-02 22:30:01 · 1525 阅读 · 0 评论 -
poj 2408 Anagram Groups(hash)
题目链接:poj 2408 Anagram Groups题目大意:给定若干个字符串,将其分组,按照组成元素相同为一组,输出数量最多的前5组,每组按照字典序输出所有字符串。数量相同的输出字典序较小的一组。解题思路:将所有的字符串统计字符后hash,排序之后确定每组的个数并且确定一组中字典序最小的字符串。根据个数以及字符串对组进行排序。#include #incl原创 2014-10-30 22:52:30 · 1657 阅读 · 0 评论 -
hdu 2609 How many(最小表示法)
题目链接:hdu 2609 How many题目大意:给出n,表示有n个有01组成的字符串,每个字符串都代表一个项链,那么该字符串就是一个环状的结构,题目要求计算说给出的字符串中有几种不同的项链。解题思路:将每个字符串转换成最小串,然后放在set里面去重。#include #include #include #include #include usi原创 2014-03-19 22:46:41 · 884 阅读 · 0 评论 -
hdu 5371 Hotaru's problem(manachar)
题目链接:hdu 5371 Hotaru's problem#include #include #include #include #include using namespace std;typedef pair pii;typedef set::iterator iter;const int maxn = 100005 * 2;int N, A[maxn];原创 2015-08-12 22:51:03 · 593 阅读 · 0 评论 -
hdu 5340 Three Palindromes(manachar)
题目链接:hdu 5340 Three Palindromes用manachar处理一下,分别找出所有包括起始位置和终止位置的回文串,然后枚举第一个串和第三个串,判断中间剩下的是否是回文。#include #include #include #include using namespace std;typedef pair pii;const int maxn原创 2015-08-12 22:36:16 · 746 阅读 · 0 评论 -
hdu 5442 Favorite Donut(最小表示法+kmp)
题目链接:hdu 5442 Favorite Donut正序逆序分别做一遍最小表示法,但是因为逆序求出最小表示法下标对应的是为最大值,所以我们用kmp求出循环节长度,然后用下标取模即可。#include #include #include #include #include #include #include using namespace std;con原创 2015-09-13 21:52:59 · 921 阅读 · 0 评论 -
Codeforces 496B Secret Combination(最小表示法)
题目链接:Codeforces 496B Secret Combination代码#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 1005;int N;char S[maxn], T[maxn], F[maxn];int miniexpress(char*原创 2015-11-10 13:16:25 · 816 阅读 · 0 评论 -
uva 10340 All in All(子串)
All in AllInput: standard inputOutput: standard outputTime Limit: 2 secondsMemory Limit: 32 MBYou have devised a new encryption technique which encodes a message by inserting between its cha原创 2013-08-18 10:58:49 · 1588 阅读 · 1 评论 -
uva 620 Cellular Structure
题目连接:620 - Cellular Structure题目大意:给出一个细胞群, 判断该细胞的可能是由哪一种生长方式的到的, 输出该生长方式的最后一种生长种类, "SIMPLE" -----------------------由 空 生成 ‘A'"FULLY-GROWN" ----------------在 原细胞群(不能为空)的后面 加上 ’AB'MUTAN原创 2013-09-10 22:52:16 · 1901 阅读 · 0 评论 -
rqn 51 乒乓球(字符串处理)
题目连接:http://www.rqnoj.cn/Problem_51.html解题思路:一次读入一个字符,对每个字符进行处理,注意的是获胜的条件除了一方到达21 或11 球之外,还有需要超过两球,就是说20:21不算分出胜负,20:22才算。#include #include #include const int N = 10005;int main() { char原创 2013-08-18 16:44:38 · 1209 阅读 · 0 评论 -
uva 644 Immediate Decodability(字符串处理)
Immediate Decodability An encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this原创 2013-07-25 00:17:32 · 1339 阅读 · 0 评论 -
uva 10010 Where's Waldorf?(DFS字符串查找)
Where's Waldorf? Given a m by n grid of letters, ( ), and a list of words, find the location in the grid at which the word can be found. A word matches a straight, uninterrupted line o原创 2013-07-24 23:26:17 · 1341 阅读 · 0 评论 -
uva 409 Excuses, Excuses!(字符串处理)
Excuses, Excuses! Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame excuses in order to avoid serving. In order to reduce the amount of time require原创 2013-07-25 01:23:34 · 2072 阅读 · 1 评论 -
uva 401 Palindromes(字符串处理)
Palindromes A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA"is a palindrome because it is the same when原创 2013-07-24 23:20:47 · 1601 阅读 · 0 评论 -
uva 10361 Automatic Poetry(字符串处理)
Automatic PoetryInput: standard inputOutput: standard outputTime Limit: 2 secondsMemory Limit: 32 MB “Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!” In Tomb原创 2013-07-24 23:35:40 · 1134 阅读 · 0 评论 -
uva 537 Artificial Intelligence?(字符串处理)
Artificial Intelligence? Physics teachers in high school often think that problems given as text are more demanding than pure computations. After all, the pupils have to read and under原创 2013-07-24 23:40:15 · 1275 阅读 · 0 评论 -
uva 327 Evaluating Simple C Expressions(遍历)
Evaluating Simple C Expressions The task in this problem is to evaluate a sequence of simple C expressions, buy you need not know C to solve the problem! Each of the expressions will a原创 2013-07-31 18:22:51 · 30842 阅读 · 0 评论 -
uva 10878 Decode the tape(字符串处理)
Decode the tapeTime Limit: 1 second"Machines take me by surprise with great frequency."Alan TuringYour boss has just unearthed a roll of old computer tapes. T原创 2013-07-24 23:44:42 · 1279 阅读 · 0 评论 -
uva 10115 Automatic Editing(strstr函数查找子串)
Automatic EditingSource file:autoedit.{c, cpp, java, pas}Input file:autoedit.inOutput file:autoedit.outText-processing tools like awk and sed allow you to aut原创 2013-07-25 00:23:39 · 1615 阅读 · 0 评论 -
hdu 3068 最长回文(manachar求最长回文子串)
题目连接:hdu 3068 最长回文解题思路:通过manachar算法求最长回文子串,如果用遍历的话绝对超时。#include #include const int N = 220005;int rad[N];char string[N], tmpstr[N];int max(int a, int b) { return a > b ? a : b;原创 2013-08-19 23:53:02 · 1402 阅读 · 0 评论 -
rqn 144 伯虎点秋香(字符串处理)
题目连接:http://www.rqnoj.cn/Problem_144.html补充题意:就是给出n个字符串,输出字典序排在第m个字符串。解题思路:借助string和sort。#include #include #include using namespace std;const int N = 10005;int main() { string str[N];原创 2013-08-18 16:49:56 · 950 阅读 · 0 评论 -
rqn 399 笨小猴(字符串处理)
题目连接:http://www.rqnoj.cn/Problem_399.html解题思路:对字符串中出现的字符逐一统计,找到最大值和最小值。#include #include const int N = 105;const int M = 26;bool isPrime(int cur) { for (int i = 2; i < cur; i++) if (cur原创 2013-08-18 16:56:33 · 1389 阅读 · 0 评论 -
uva 310 L--system(隐式图搜索+字符串处理)
L-system A D0L (Deterministic Lindenmayer system without interaction) system consists of a finite set of symbols (the alphabet), a finite set P of productions and a starting string原创 2013-08-17 21:31:45 · 1950 阅读 · 7 评论 -
rqn 137 找试场(模拟)
题目连接:http://www.rqnoj.cn/Problem_137.html解题思路:模拟,水题一道,看代码。#include #include const int N = 10;const int r[] = {1, 2, 3, 0};const int l[] = {3, 0, 1, 2};int n;char order[N];int main() {原创 2013-08-18 16:38:45 · 1108 阅读 · 0 评论 -
rqn 224 手机(常量数组)
题目连接:http://www.rqnoj.cn/Problem_224.html解题思路:将对应按键存成常量数组。#include #include const int sign[] = {1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4};const int N = 205;原创 2013-08-18 16:52:52 · 1077 阅读 · 0 评论 -
rqn 516 多项式输出(字符串输出处理)
题目连接:http://www.rqnoj.cn/Problem_516.html解题思路:分类考虑一下。1、第一个'+'不用输出;2、系数为1不输出;3、幂为1不输出;4、系数为0整项不输出。#include #include #include const int N = 105;int main() { int n, num[N]; whil原创 2013-08-18 17:00:28 · 1195 阅读 · 0 评论 -
uva 719 - Glass Beads(最小表示法 | 后缀自动机)
题目链接:uva 719 - Glass Beads题目大意:给定一个字符串,求最小表示法。解题思路:最小表示法。#include #include #include using namespace std;const int maxn = 1e4+5;char s[maxn];int main () { int cas; scanf("%d原创 2014-09-04 23:11:08 · 2073 阅读 · 0 评论