随笔分类 -  字符串

摘要:"题目链接" Problem Description哈利波特在魔法学校的必修课之一就是学习魔咒。据说魔法世界有100000种不同的魔咒,哈利很难全部记住,但是为了对抗强敌,他必须在危急时刻能够调用任何一个需要的魔咒,所以他需要你的帮助。给你一部魔咒词典。当哈利听到一个魔咒时,你的程序必须告诉他那... 阅读全文
posted @ 2015-11-14 15:56 Oyking 阅读(415) 评论(0) 推荐(0)
摘要:题目链接:http://hihocoder.com/contest/msbop2015qual/problemsA.2月29日首先为了方便处理可以分类一下把问题转化成第a年到第b年的闰年数量。然后如果要求fun(x)=1~x年中闰年的数量,容斥一下就是 (1~x中4的倍数) -(1~x中100的倍数... 阅读全文
posted @ 2015-04-21 17:41 Oyking 阅读(347) 评论(2) 推荐(0)
摘要:Dr. X is a biologist, who likes rabbits very much and can do everything for them. 2012 is coming, and Dr. X wants to take some rabbits to Noah's Ark, ... 阅读全文
posted @ 2014-09-04 18:20 Oyking 阅读(251) 评论(0) 推荐(0)
摘要:Problem Description刚学完后缀数组求回文串的瑶瑶(tsyao)想到了另一个问题:如果能够对字符串做一些修改,怎么在每次询问时知道以某个字符为中心的最长回文串长度呢?因为瑶瑶整天只知道LOL,当他知道自己省选成绩的时候就天天在LOL,导致现在的她实在是太弱了,根本解决不了这个问题,于... 阅读全文
posted @ 2014-08-07 10:49 Oyking 阅读(333) 评论(0) 推荐(0)
摘要:Problem DescriptionThere is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although th... 阅读全文
posted @ 2014-08-05 00:10 Oyking 阅读(440) 评论(0) 推荐(0)
摘要:Problem Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要求,则就是新的完美队形: 1、挑出的人保持原队形的相对顺... 阅读全文
posted @ 2014-05-02 16:20 Oyking 阅读(355) 评论(0) 推荐(0)
摘要:1、AC自动机 1 void buildTrie(Node *root, char *str){ 2 Node *p = root; 3 for(int i = 0; str[i]; ++i){ 4 int index = str[i] - '0'; ... 阅读全文
posted @ 2014-04-21 11:33 Oyking 阅读(229) 评论(0) 推荐(0)
摘要:In the present world you frequently meet a lot of call numbers and they are going to be longer and longer. You need to remember such a kind of numbers. One method to do it in an easy way is to assign letters to digits as shown in the following picture:1 ij 2 abc 3 def4 gh 5 kl 6 mn7 prs ... 阅读全文
posted @ 2014-02-22 22:10 Oyking 阅读(1594) 评论(0) 推荐(0)
摘要:You are the King of Byteland. Your agents have just intercepted a batch of encrypted enemy messages concerning the date of the planned attack on your island. You immedietaly send for the Bytelandian Cryptographer, but he is currently busy eating popcorn and claims that he may only decrypt the most i 阅读全文
posted @ 2014-02-04 15:08 Oyking 阅读(425) 评论(0) 推荐(0)
摘要:DescriptionYou may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, eyebrows and the like. A few bear no human resemblance; these typically have geometric or amorphous shapes like cubes, oil slicks or clouds o 阅读全文
posted @ 2014-02-03 22:50 Oyking 阅读(256) 评论(0) 推荐(0)
摘要:DescriptionA substring of a stringTis defined as:T(i,k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|.Given two stringsA,Band one integerK, we defineS, a set of triples (i,j,k):S= {(i,j,k) |k≥K,A(i,k)=B(j,k)}.You are to give the value of |S| for specificA,BandK.InputThe input file contains several blocks of data. 阅读全文
posted @ 2014-02-02 00:14 Oyking 阅读(757) 评论(0) 推荐(0)
摘要:DescriptionThe repetition number of a string is defined as the maximum numberRsuch that the string can be partitioned intoRsame consecutive substrings. For example, the repetition number of "ababab" is 3 and "ababa" is 1.Given a string containing lowercase letters, you are to fin 阅读全文
posted @ 2014-02-01 20:41 Oyking 阅读(295) 评论(0) 推荐(0)
摘要:DescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a^0 = " 阅读全文
posted @ 2014-01-31 17:56 Oyking 阅读(1807) 评论(0) 推荐(1)
摘要:The “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent from the competing «Robots Unlimited» has infiltrated into “U.S. Robotics”. «U.S. Robots» security service would have already started an undercover operation to establish the agent 阅读全文
posted @ 2014-01-29 23:08 Oyking 阅读(358) 评论(0) 推荐(0)
摘要:Given a string, we need to find the total number of its distinct substrings.InputT- number of test cases. T 2 #include 3 #include 4 #include 5 using namespace std; 6 typedef long long LL; 7 8 const int MAXN = 50010; 9 10 int sa[MAXN], c[MAXN], rank[MAXN], height[MAXN], tmp[MAXN];11 char s[MAXN];... 阅读全文
posted @ 2014-01-29 21:28 Oyking 阅读(393) 评论(0) 推荐(0)
摘要:DescriptionFarmer John has noticed that the quality of milk given by his cows varies from day to day. On further investigation, he discovered that although he can't predict the quality of milk from one day to the next, there are some regular patterns in the daily milk quality.To perform a rigoro 阅读全文
posted @ 2014-01-27 22:31 Oyking 阅读(232) 评论(0) 推荐(0)
摘要:DescriptionA musical melody is represented as a sequence of N (1 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int MAXN = 20010; 8 int s[MAXN]; 9 int n, sa[MAXN], height[MAXN], rank[MAXN], tmp[MAXN], c[MAXN];10 11 void makesa(int m) {12 memset(c, 0, sizeof(c));13 for(... 阅读全文
posted @ 2014-01-27 19:55 Oyking 阅读(265) 评论(0) 推荐(0)
摘要:Description“Be subtle! Be subtle! And use your spies for every kind of business. ”― Sun Tzu“A spy with insufficient ability really sucks”― An anonymous general who lost the warYou, a general, following Sun Tzu’s instruction, make heavy use of spies and agents to gain information secretly in order to 阅读全文
posted @ 2013-10-19 13:43 Oyking 阅读(309) 评论(0) 推荐(0)
摘要:Problem DescriptionIn this problem, you are given several strings that contain only digits from '0' to '9', inclusive.An example is shown below.101123The set S of strings is consists of the N strings given in the input file, and all the possible substrings of each one of them.It' 阅读全文
posted @ 2013-10-06 22:16 Oyking 阅读(339) 评论(0) 推荐(0)
摘要:A string is finite sequence of characters over a non-empty finite set Σ.In this problem, Σ is the set of lowercase letters.Substring, also called factor, is a consecutive sequence of characters occurrences at least once in a string.Now your task is a bit harder, for some given strings, find the leng 阅读全文
posted @ 2013-10-06 16:33 Oyking 阅读(482) 评论(0) 推荐(0)