
字符串
字符串
chr1st0pher
Dancer on the keyboard
展开
-
2020 CCPC 威海 G. Caesar Cipher(Hash + 线段树)
DescriptionInput5 61 2 1 2 12 1 2 22 1 3 31 1 11 3 52 1 2 42 1 2 2OutputnoyesnoyesSolution题意很明了,就是两种操作,一种是对区间每个数+1再mod 65536,另一种则是判断两个区间的数是否相同很容易想到用线段树维护区间Hash值的和,区间+1等价于Hash值+=base值然而本题的关键在于每个数都是在mod 65536意义下的,每当+1到65536时,就变成0了,而此时的Hash原创 2020-11-16 22:36:29 · 241 阅读 · 5 评论 -
BZOJ 1954 The xor-longest Path (01 Trie + 贪心)
Description给定一棵n个点的带权树,求树上最长的异或和路径InputThe input contains several test cases. The first line of each test case contains an integer n(1<=n<=100000), The following n-1 lines each contains three integers u(0 <= u < n),v(0 <= v < n),w(0 &l原创 2020-07-19 10:39:34 · 190 阅读 · 0 评论 -
Gym - 102448A Accept or Reject (Manacher)
DescriptionThis semester, various UFPE competitors had classes of a discipline called Theoretical Informatics. One of the major studied concepts was Turing Machines ™.A TM is basically a system that has a tape with infinite memory cells to the right and原创 2020-07-03 19:33:49 · 257 阅读 · 0 评论 -
Codeforces 159D. Palindrome pairs (Manacher +DP)
DescriptionYou are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.In a more formal way, you have to find the quantity of tuples (a, b, x, y) such that 1 ≤ a ≤原创 2020-07-15 23:41:33 · 430 阅读 · 0 评论 -
HDU 4513 吉哥系列故事——完美队形II (Manacher)
Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] … h[n],吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要求,则就是新的完美队形:1、挑出的人保持原队形的相对顺序不变,且必须都是在原队形中连续的;2、左右对称,假设有m个人形成新的队形,则第1个人和第m个人身高相同,第2个人和第m-1个人身高相同,依此类推,当然如果m是奇数,中间那个人可以任意;3、从左到中间那个人,身高需保证不下降,原创 2020-07-17 21:58:42 · 180 阅读 · 0 评论 -
Codeforces 1326D. Prefix-Suffix Palindrome (Manacher)
DescriptionYou are given a string s, consisting of lowercase English letters. Find the longest string, t, which satisfies the following conditions:1.The length of t does not exceed the length of s.2.t is a palindrome.3.There exists two strings a and b原创 2020-07-27 23:03:58 · 263 阅读 · 0 评论 -
Luogu P4555 [国家集训队]最长双回文串 (Manacher)
Description顺序和逆序读起来完全一样的串叫做回文串。比如acbca是回文串,而abc不是(abc的顺序为abc,逆序为cba,不相同)。输入长度为nnn的串SSS,求SSS的最长双回文子串TTT,即可将TT分为两部分XXX,YYY,(∣X∣,∣Y∣≥1|X|,|Y|≥1∣X∣,∣Y∣≥1)且XXX和YYY都是回文串。Input一行由小写英文字母组成的字符串SS。Output一行一个整数,表示最长双回文子串的长度。ExamplesInputbaacaabbacabbOutput原创 2020-07-27 23:19:27 · 184 阅读 · 0 评论 -
Codeforces 432D. Prefixes and Suffixes (DP + next数组)
DescriptionYou have a string s = s 1 s 2…s |s|, where |s| is the length of string s, and s i its i-th character.Let’s introduce several definitions:A substring s[i…j] (1 ≤ i ≤ j ≤ |s|) of string s is string s i s i + 1…s j.The prefix of string s of len原创 2020-07-24 21:59:01 · 265 阅读 · 0 评论 -
Gym 102218K. K-th Missing Digit (Hash / 数论)
DescriptionYou’re given two positive integers A and B, and a string P, representing their product but with a missing digit indicated with an ∗. Find the missing digit.It’s guaranteed that the missing digit isn’t 0.InputThe first line contains three int原创 2020-08-10 20:35:38 · 210 阅读 · 0 评论 -
Codeforces 126B. Password (Next 数组 + DP / Hash)
DescriptionAsterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.A little later they found a string s, carved on a rock below the原创 2020-07-28 10:15:51 · 253 阅读 · 0 评论