- 博客(30)
- 收藏
- 关注
原创 CodeForces985D- Sand Fortress(二分)
DescriptionYou are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spots to pile up sand pillars. Spots are numbered 1
2020-05-20 11:18:37
332
原创 CodeForces361D- Lekvo and Array(二分+dp)
DescriptionLevko has an array that consists of integers: a 1, a 2, … , a n. But he doesn’t like this array at all.Levko thinks that the beauty of the array a directly depends on value c(a), which can be calculated by the formula:The less value c(a) is,
2020-05-19 21:37:40
228
原创 CodeForces1175E- Minimal Segment Cover(倍增)
DescriptionYou are given n intervals in form [l;r] on a number line.You are also given m queries in form [x;y]. What is the minimal number of intervals you have to take so that every point (not necessarily integer) from x to y is covered by at least one
2020-05-18 23:48:22
357
原创 CodeForces732D- Exams(二分+贪心)
DescriptionVasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.About every day we know exam for which one of m subjects can be passed on that day. Perhaps, some day you can’t pa
2020-05-18 21:44:09
270
原创 CodeForces372B- Counting Rectangles is Fun(dp)
DescriptionThere is an n × m rectangular grid, each cell of the grid contains a single integer: zero or one. Let’s call the cell on the i-th row and the j-th column as (i, j).Let’s define a “rectangle” as four integers a, b, c, d (1 ≤ a ≤ c ≤ n; 1 ≤ b ≤
2020-05-17 00:13:42
239
原创 POJ2228- Naptime(环形dp)
DescriptionGoneril is a very sleep-deprived cow. Her day is partitioned into N (3 <= N <= 3,830) equal time periods but she can spend only B (2 <= B < N) not necessarily contiguous periods in bed. Due to her bovine hormone levels, each period
2020-05-09 23:52:31
379
原创 UVALive 4794- Sharing Chocolate(枚举子集dp)
DescriptionChocolate in its many forms is enjoyed by millions of people around the world every day. It is a truly universal candy available in virtually every country around the world.You find that ...
2020-05-07 18:19:30
212
原创 UVA11825- Hacker’s Crackdown(枚举子集dp)
DescriptionMiracle Corporations has a number of system services running in a distributed computer system which is a prime target for hackers. The system is basically a set of N computer nodes with ea...
2020-05-06 22:01:19
174
原创 CodeForces335B- Palindrome(最长公共子序列)
Given a string s, determine if it contains any palindrome of length exactly 100 as a subsequence. If it has any, print any one of them. If it doesn’t have any, print a palindrome that is a subsequence...
2020-04-21 13:27:46
355
原创 CodeForces808E- Selling Souvenirs(背包)
DescriptionAfter several latest reforms many tourists are planning to visit Berland, and Berland people understood that it’s an opportunity to earn money and changed their jobs to attract tourists. P...
2020-04-17 19:19:26
265
原创 CodeForces17E- Palisection(manacher)
DescriptionIn an English class Nick had nothing to do at all, and remembered about wonderful strings called palindromes. We should remind you that a string is called a palindrome if it can be read th...
2020-04-05 13:59:58
265
原创 HYSBZ- 弦论(后缀自动机)
Description对于一个给定长度为N的字符串,求它的第K小子串是什么。Input第一行是一个仅由小写英文字母构成的字符串S第二行为两个整数T和K,T为0则表示不同位置的相同子串算作一个。T=1则表示不同位置的相同子串算作多个。K的意义如题所述。Output输出仅一行,为一个数字串,为第K小的子串。如果子串数目不足K个,则输出-1Sample Inputaabc 0 3Sam...
2020-03-31 00:28:00
220
原创 UVA1673- str2int(后缀自动机)
Description题意:有多组数据,每组数据给出n个由0~9构成的数字串,求所有子串构成的不同整数之和对2012取模,忽略前导0(也就是说01和1是一样的)。解法:考虑把所有的字符串一起放入后缀自动机(注意为了区分不同的串,两个串之间要插入一个不属于0~9的字符,这里选的是10,每次遍历时只要跳过10的分支就可以了),这样相同的字符串就会被直接去掉。用cnt数组表示字符出现次数,s...
2020-03-30 19:00:44
180
原创 HDU4622- Reincarnation(后缀自动机)
DescriptionNow you are back,and have a task to do:Given you a string s consist of lower-case English letters only,denote f(s) as the number of distinct sub-string of s.And you have some query,each ...
2020-03-29 01:33:40
202
原创 CodeForces123D- String(后缀数组)
DescriptionYou are given a string s. Each pair of numbers l and r that fulfill the condition 1 ≤ l ≤ r ≤ |s|, correspond to a substring of the string s, starting in the position l and ending in the p...
2020-03-28 16:14:19
384
原创 CodeForces427D- Match&Catch(后缀数组)
DescriptionPolice headquarter is monitoring signal on different frequency levels. They have got two suspiciously encoded strings s1 and s2 from two different frequencies as signals. They are suspecti...
2020-03-26 14:23:08
204
原创 POJ1204- Word Puzzles(字典树)
DescriptionWord puzzles are usually simple and very entertaining for all ages. They are so entertaining that Pizza-Hut company started using table covers with word puzzles printed on them, possibly w...
2020-03-22 21:10:34
663
原创 CodeForces1285D- Dr.Evil Underscores(字典树)
Description:Today, as a friendship gift, Bakry gave Badawy nn integers a1,a2,…,ana1,a2,…,an and challenged him to choose an integer XX such that the value max1≤i≤n(ai⊕X)max1≤i≤n(ai⊕X) is minimum poss...
2020-03-22 18:06:24
156
原创 CodeForces1150D- Three Religions(字符串dp)
Description:During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on ...
2020-03-22 16:25:32
269
原创 POJ3356- AGTC(dp)
Description:Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below:Deletion: a letter in x is missing in y at a correspondi...
2020-03-18 22:44:09
310
原创 CodeForces1183H- Subsequences(hard version)(dp)
Description:The only difference between the easy and the hard versions is constraints.A subsequence is a string that can be derived from another string by deleting some or no symbols without changin...
2020-03-18 20:56:08
464
原创 UVA10617- Again Palindrome(dp)
题意:给出t个字符串,输出每个字符串包含的回文子串数量。解法:利用dp和容斥。设dp[i][j]为i到j的回文子串的数量,则有dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1](即i到j的回文子串=i+1到j的回文子串+i到j-1的回文子串-重复的回文子串)。注意若是s[i]==s[j],则i+1到j-1中的所有回文子串都可以和i和j一起组成一个新的回文...
2020-03-18 19:26:35
192
原创 UVA12338- Anti-Rhyme Pairs(哈希+二分)
题意:有t组问题,每组给出n个字符串和q个询问,每个询问给出位置i和j,问第i个字符串和第j个字符串的最长公共前缀的长度。解法:首先对每个字符串的每个位置进行hash,存入不定长数组vector中,对每个询问用二分查找使得shash[i][mid]==shash[j][mid]的最大的mid。代码:#include<iostream>#include<cstdio&...
2020-03-18 17:52:14
209
原创 CodeForces1096D- Easy Problem(dp)
Description:Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length n consisting of lowercase Latin latters. Vasya thinks that the st...
2020-03-18 17:40:56
217
原创 CodeForces961F- k-substrings(哈希)
Description:You are given a string s consisting of n lowercase Latin letters.Let’s denote k-substring of s as a string subsk = sksk + 1…sn + 1 - k. Obviously, subs1 = s, and there are exactly such ...
2020-03-15 16:39:34
340
原创 HDU4821 - String(哈希)
Description:Given a string S and two integers L and M, we consider a substring of S as “recoverable” if and only if(i) It is of length M*L;(ii) It can be constructed by concatenating M “diversified...
2020-03-15 15:57:00
324
原创 CodeForces985F - Isomorphic Strings(同构字符串+哈希)
Description:You are given a string s of length n consisting of lowercase English letters.For two given strings s and t, say S is the set of distinct characters of s and T is the set of distinct char...
2020-03-15 14:54:13
474
原创 POJ3960 - Constellations(二维哈希)
ProblemThe starry sky in the summer night is one of the most beautiful things on this planet. People imagine that some groups of stars in the sky form so-called constellations. Formally a constellati...
2020-03-11 13:03:40
245
原创 Codeforces1137B - Camp Schedule(KMP中的next数组)
ProblemThe new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp’s schedule. After...
2020-03-10 23:24:11
282
原创 Codeforces898F - Restoring the Expression(字符串哈希+枚举)
Codeforces898F - Restoring the ExpressionA correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs...
2020-03-10 23:04:35
382
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅