
acm之路--字符串
文章平均质量分 81
synapse7
这个作者很懒,什么都没留下…
展开
-
Manacher 算法详解:O(n) 复杂度求最长回文子串
先预处理下:在每个字符的两边都插入一个特殊的符号,比如abba变成#a#b#b#a#,aba变成#a#b#a#(因为Manacher算法只能处理奇数长度的字符串)。同时,为了避免数组越界,在字符串开头添加另一特殊符号,比如$#a#b#a#。以字符串3212343219为例,处理后变成S[] = "$#3#2#1#2#3#4#3#2#1#9#"。然后用一个数组Len[i]来记录以字符S[i原创 2014-02-03 12:27:09 · 4408 阅读 · 2 评论 -
UVa 123 Searching Quickly (使用STL replace进行字符串替换)
123 - Searching QuicklyTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=59BackgroundSearching and sorti原创 2013-10-21 21:00:09 · 1118 阅读 · 0 评论 -
UVa 400 Unix ls (字符串排序&规格化输出)
400 - Unix lsTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=341The computer company you work for is intro原创 2013-10-21 18:25:47 · 1345 阅读 · 0 评论 -
UVa 10361 Automatic Poetry (字符串处理&两种读入方式)
10361 - Automatic PoetryTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1302“Oh God”, Lara Croft exclaim原创 2013-09-28 23:04:06 · 1091 阅读 · 0 评论 -
UVa 10921 Find the Telephone (water ver.)
10921 - Find the TelephoneTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1862In some places is common to原创 2013-10-19 12:41:34 · 1137 阅读 · 0 评论 -
UVa 10878 Decode the tape (趣题)
10878 - Decode the tapeTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1819"Machines take me by su原创 2013-09-29 00:13:31 · 909 阅读 · 0 评论 -
UVa 409 Excuses, Excuses! (字符串匹配)
409 - Excuses, Excuses!Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=350Judge Ito is having a problem wi原创 2013-09-28 23:46:12 · 909 阅读 · 0 评论 -
UVa 644 Immediate Decodability (前缀匹配)
644 - Immediate DecodabilityTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=585An encoding of a set of sym原创 2013-09-29 08:41:06 · 1108 阅读 · 2 评论 -
UVa 10815 Andy's First Dictionary (分离字符串)
10815 - Andy's First DictionaryTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1756Andy, 8, has a dream -原创 2013-09-29 08:24:12 · 1641 阅读 · 0 评论 -
TZC 1472 逆置正整数,去前导零 (java一句话秒杀)
逆置正整数http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1472时间限制(普通/Java):1000MS/10000MS 运行内存限制:65536KByte描述输入一个三位正整数,将它反向输出。输入3位正原创 2013-10-30 09:35:36 · 2032 阅读 · 1 评论 -
UVa 401 Palindromes (字符串匹配)
401 - PalindromesTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=342A regular palindrome is a string of nu原创 2013-09-28 16:33:40 · 1297 阅读 · 1 评论 -
UVa 748 / POJ 1001 Exponentiation (浮点高精度求幂&正则表达式的应用)
str = str.replaceFirst("^0*", "");原创 2013-10-20 23:07:21 · 1485 阅读 · 0 评论 -
类型转换与字符串赋值、分割、合并、复制、比较、查询、翻转详解 (完整代码)
一、类型转换char数组转int、__int64或double:#include#include#include#includechar str[100];int main(void){ char *stopstr; gets(str); if (strchr(str, '.') == NULL) { if (strlen(str) < 10) print原创 2013-08-24 20:44:46 · 2953 阅读 · 1 评论 -
LightOJ 1255 Substring Frequency (KMP模板)
http://lightoj.com/volume_showproblem.php?problem=1255/*0.068s,7548KB*/#includeusing namespace std;const int mx = 1000005;char t[mx], p[mx];int f[mx];void getfail(){ f[0] = f[1] = 0原创 2014-03-26 23:27:28 · 1447 阅读 · 0 评论 -
LightOJ 1258 Making Huge Palindromes (回文&KMP)
http://lightoj.com/volume_showproblem.php?problem=1258首先原串+翻转过来的串必然是一个回文串,但是二者在中间可以“融合”,而KMP算法恰好可以求出最大融合长度。所以看翻转过来的串能匹配多少原串即可,答案就是len+(len-匹配个数)。完整代码:/*0.140s,7548KB*/#includeusin原创 2014-03-27 13:40:28 · 1834 阅读 · 0 评论 -
UVa 1328 Period (KMP&失配函数的理解)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=505&page=show_problem&problem=4074令失配函数为f[i],由失配函数的定义可知i-f[i]就是最小重复子串的长度。完整代码:/*0.100s*/#includeconst int原创 2014-03-07 22:54:09 · 1166 阅读 · 0 评论 -
UVa 11988 Broken Keyboard (a.k.a. Beiju Text) (指针的"思想")
11988 - Broken Keyboard (a.k.a. Beiju Text)Time limit: 1.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3139You're typi原创 2013-10-03 16:21:17 · 2323 阅读 · 0 评论 -
UVa 1401 Remember the Word (Trie树模板题)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=505&page=show_problem&problem=4147递推写法:L = strlen(text);for (i = L - 1; i >= 0; --i){ trie.find_prefixes(text +原创 2014-03-02 09:31:51 · 1083 阅读 · 0 评论 -
【优化】Codeforces Beta Round #1 / 1B Spreadsheets (字符串处理)
B. Spreadsheetshttp://codeforces.com/problemset/problem/1/Btime limit per test10 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output原创 2013-08-18 11:06:34 · 1465 阅读 · 0 评论 -
UVa 10340 All in All (字符串处理&编程技巧)
10340 - All in AllTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=457&page=show_problem&problem=1281You have devised a new encryption原创 2013-09-02 20:58:01 · 1001 阅读 · 0 评论 -
UVa 537 Artificial Intelligence? (字符串查找与匹配)
537 - Artificial Intelligence?Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=478Physics teachers in high原创 2013-09-28 23:21:02 · 1142 阅读 · 0 评论 -
UVa 642 Word Amalgamation (查字典&字符串排序)
642 - Word AmalgamationTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=583In millions of newspapers across the United States there原创 2013-09-28 00:08:44 · 1358 阅读 · 0 评论 -
UVa 455 Periodic Strings (字符串处理)
455 - Periodic StringsTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=396A character string is said to have period k if it can be f原创 2013-09-27 19:51:29 · 2504 阅读 · 0 评论 -
Codeforces Round #186 (Div. 2) / 313B Ilya and Queries (字符串处理)
B. Ilya and Queriestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya the Lion wants to help all his fri原创 2013-08-29 10:01:41 · 1706 阅读 · 0 评论 -
Codeforces VK Cup 2012 Qualification Round 1 /158C (字符串处理)
C. Cd and pwd commandshttp://codeforces.com/problemset/problem/158/Ctime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard原创 2013-08-28 23:36:53 · 1076 阅读 · 0 评论 -
Codeforces Round #163 (Div. 2) / 226A Stones on the Table (字符串处理)
A. Stones on the Tablehttp://codeforces.com/problemset/problem/266/Atime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard原创 2013-08-23 15:38:20 · 1122 阅读 · 0 评论 -
Codeforces Round #173 (Div. 2) / 282C XOR and OR (字符串处理)
C. XOR and ORhttp://codeforces.com/problemset/problem/282/Ctime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2013-08-22 23:40:51 · 1497 阅读 · 0 评论 -
HDU 4608 I-number (数学&字符串处理)
I-numberhttp://acm.hdu.edu.cn/showproblem.php?pid=4608Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionThe I-numbe原创 2013-08-22 18:05:05 · 912 阅读 · 0 评论 -
Codeforces Beta Round #70 (Div. 2) / 78A Haiku (字符串处理)
A. Haikuhttp://codeforces.com/problemset/problem/78/Atime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputH原创 2013-08-22 09:05:53 · 1110 阅读 · 0 评论 -
Codeforces Beta Round #89 (Div. 2) / 118A String Task(字符串操作)
A. String Taskhttp://codeforces.com/problemset/problem/118/Atime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2013-08-21 15:26:34 · 1173 阅读 · 0 评论 -
POJ 2271 HTML (字符串处理)
HTMLhttp://poj.org/problem?id=2271Time Limit: 1000MSMemory Limit: 65536KDescriptionIf you ever tried to read a html document on a Macintosh, you know how hard it is if no N原创 2013-08-29 19:29:50 · 1045 阅读 · 0 评论 -
Seoul 2006 / UVa 1368 DNA Consensus String (字符串处理)
1368 - DNA Consensus StringTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=457&page=show_problem&problem=4114 Figure 1.DNA (Deoxyribo原创 2013-09-02 10:20:00 · 976 阅读 · 0 评论 -
POJ 1068 Parencodings (字符串处理)
Parencodingshttp://poj.org/problem?id=1068Time Limit: 1000MSMemory Limit: 10000KDescriptionLet S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in t原创 2013-08-28 21:32:11 · 846 阅读 · 0 评论 -
UVa 10010 Where's Waldorf? (八方向字符串匹配&模板题)
10010 - Where's Waldorf?Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=951Given a m by n grid of letter原创 2013-09-28 18:13:02 · 1201 阅读 · 0 评论 -
4th IIUC Inter-University Programming Contest, 2005 / UVa 10905 Children's Game (等长转化技巧)
10905 - Children's GameTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=512&page=show_problem&problem=1846There are lots of number games原创 2013-09-02 13:16:55 · 1353 阅读 · 0 评论 -
UVa 10082 WERTYU (water ver.)
10082 - WERTYUTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1023A common typing error is to place the ha原创 2013-09-21 06:44:13 · 1449 阅读 · 0 评论 -
UVa 10008 What's Cryptanalysis? (water ver.)
10008 - What's Cryptanalysis?Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=949Cryptanalysis is the process原创 2013-09-21 10:21:51 · 1580 阅读 · 0 评论 -
UVa 10115 Automatic Editing (字符串中间替换技巧)
10115 - Automatic EditingTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1056Text-processing tools like aw原创 2013-09-29 09:24:02 · 1360 阅读 · 0 评论 -
UVa 458 The Decoder (最简代码!)
458 - The DecoderTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=399Write a complete program that will cor原创 2013-09-13 11:29:39 · 1431 阅读 · 0 评论 -
UVa 489 Hangman Judge (模拟&字符串匹配)
489 - Hangman JudgeTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=430In ``Hangman Judge,'' you are to wri原创 2013-09-13 23:54:10 · 1031 阅读 · 0 评论