1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is ofte…
1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is of…
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistic…
https://pintia.cn/problem-sets/994805342720868352/problems/994805390896644096 The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality.…
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistic…
题目信息 1077. Kuchiguse (20) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a prefere…
Musical Theme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15900   Accepted: 5494 Description A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the…
题目描述 如果一个字符串可以被拆分为AABBAABB的形式,其中 A和 B是任意非空字符串,则我们称该字符串的这种拆分是优秀的. 例如,对于字符串aabaabaaaabaabaa,如果令 A=aabA=aab,B=aB=a,我们就找到了这个字符串拆分成 AABBAABB的一种方式. 一个字符串可能没有优秀的拆分,也可能存在不止一种优秀的拆分.比如我们令 A=aA=a,B=baaB=baa,也可以用 AABBAABB表示出上述字符串:但是,字符串 abaabaaabaabaa 就没有优秀的拆分.…
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is ofte…
1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is of…
1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often…
题目描述 绿绿和 Yazid 是好朋友.他们在一起做串串游戏. 我们定义翻转的操作:把一个串以最后一个字符作对称轴进行翻转复制.形式化地描述就是,如果他翻转的串为 RRR,那么他会将前 ∣R∣−1个字符倒序排列后,插入到串的最后. 举例而言,串abcd进行翻转操作后,将得到abcdcba:串qw连续进行 2次翻转操作后,将得到qwqwq:串z无论进行多少次翻转操作,都不会被改变. 贪玩的绿绿进行了若干次(可能为 0 次)翻转操作. 淘气的绿绿又展示出了一个非空串 S,并表示 S 是最终的串 R…
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is ofte…
题意 给出两个字符串\(s\)和\(t\),设\(S\)为\(s\)的任意一个非空前缀,\(T\)为\(t\)的任意一个非空前缀,问\(S+T\)有多少种不同的可能. Solution 看了一圈,感觉好像就我一个人写的\(kmp+hash+\)二分. 直接算好像不是很好算?先容斥一下,不同\(=\)总方案\(-\)相同. 显然总方案为两个字符串的长度的乘积,考虑相同的情况怎么算. 相同即两组\(S\)和\(T\)不同,但\(S+T\)本质相同的情况. 这个东西怎么算呢.... (感觉看图会好理解…
题目大意:一个字符串三个操作:①求两个后缀的LCP②插入一个字符③修改一个字符. 前几天刚学了hash+二分求lcp,就看到这题. 原来splay还能这么用?!原来splay模板这么好写?我以前写的splay是假的吧woc splay每个节点代表一个字符,并维护这个子树代表一个子串的哈希值.因为splay旋转不破坏树结构,所以不论怎么旋转这棵splay树都能代表这个字符串. 预处理处理少了调了半天呜呜呜 赶紧跑去更新自己的splay模板 #include<iostream> #include&…
后缀数组倍增算法超时,听说用3DC可以勉强过,不愿写了,直接用hash+二分求出log(n)的时间查询两个字符串之间的任意两个位置的最长前缀. 我自己在想hash的时候一直在考虑hash成数值时MOD取多大,如果取10^18的话,那么两数相乘个就超LL了,但是取10^9的话又怕出现重复的可能大.后面才发现自己是sb,如果用unsigned long long 如果有溢出或者为负数是直接变成对(1<<64)取模了. 也就是无符号长整形运算自动帮你取模了.所以可以放心用hash Justice S…
题目描述 火星人最近研究了一种操作:求一个字串两个后缀的公共前缀.比方说,有这样一个字符串:madamimadam,我们将这个字符串的各个字符予以标号:序号: 1 2 3 4 5 6 7 8 9 10 11 字符 m a d a m i m a d a m 现在,火星人定义了一个函数LCQ(x, y),表示:该字符串中第x个字符开始的字串,与该字符串中第y个字符开始的字串,两个字串的公共前缀的长度.比方说,LCQ(1, 7) = 5, LCQ(2, 10) = 1, LCQ(4, 7) = 0…
http://www.lydsy.com/JudgeOnline/problem.php?id=1014 题意:支持插入一个字符.修改一个字符,查询lcp.(总长度<=100000, 操作<=150000) #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm&…
string是最简单的类型,一个key对应一个value,string类型是二进制安全的.redis的string可以包含任何数据,比如JPG图片或者序列化的对象 操作    set    设置key对应的值为string类型的value    例如:    set name haoxing   //设置key为那么value为haoxiang    get name   //会得到“haoxiang”        注意:    set 重复添加相同的key名会覆盖原来的值 setnx    …
[题目]F. k-substrings [题意]给定长度为n的串S,对于S的每个k-子串$s_ks_{k+1}...s_{n-k+1},k\in[1,\left \lceil \frac{n}{2} \right \rceil]$,找到满足[奇数长度][严格子串][同时是前缀和后缀]的最长子串.n<=10^6. [算法]字符串哈希+二分 [题解]任意两个对应子串,它们有一个不变量——它们的中心一定是i和n-i+1.而且固定中心之后,能延伸的最长相等子串是可以二分+哈希得到的. 所以枚举k,二分+…
https://blog.csdn.net/webnum/article/details/78313525   分片规则:字符串拆分hash 一.conf/schema.xml文件   <?xml version="1.0"?>   <!DOCTYPE mycat:schema SYSTEM "schema.dtd">   <mycat:schema xmlns:mycat="http://io.mycat/">…
题目 题目地址:PAT 乙级 1077 题解 本题没什么难度,但是要注意细节问题,下面简单来说一下: vector 把输入的学生打分存起来,直接用算法库中的 sort 函数给它们排个序,之后直接剔除首尾两端的元素,之后简单算个平均就解决了问题: 代码过程中需要注意的有两点: 1. 获得一行整数输入 使用 cin.get() 接收 '\n' 判断本行输入是否结束即可:贴一段样例代码 #include <iostream> #include <vector> using namespa…
题目链接 : https://www.acwing.com/problem/content/description/142/ Hash + 二分 #include <bits/stdc++.h> using namespace std; ; typedef unsigned long long ull; ; ull p[maxn],h[maxn]; int sa[maxn],rank[maxn],height[maxn]; char str[maxn]; int n ; ull get(int…
题意: 输入一个正整数N(<=100),接着输入N行字符串.输出N行字符串的最长公共后缀,否则输出nai. AAAAAccepted code: #include<bits/stdc++.h> using namespace std; ]; ]; ]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; cin.ignore(); ; ;i<=n;+…
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> using namespace std; /* 找最长相同后缀 */ ; ]; ]; int len[maxn]; int main() { int n; ; ; scanf("%d",&n); getchar(); ;i<…
Long Long Message Problem's Link:http://poj.org/problem?id=2774 Mean: 求两个字符串的最长公共子串的长度. analyse: 前面在学习后缀数组的时候已经做过一遍了,但是现在主攻字符串hash,再用字符串hash写一遍. 这题的思路是这样的: 1)取较短的串的长度作为high,然后二分答案(每次判断长度为mid=(low+high)>>1是否存在,如果存在就增加下界:不存在就缩小上界): 2)主要是对答案的判断(judge函数…
Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient algorithm to find the length of the largest palindrome in a string?" A string is sai…
1402 后缀数组 0x10「基本数据结构」例题 描述 后缀数组 (SA) 是一种重要的数据结构,通常使用倍增或者DC3算法实现,这超出了我们的讨论范围.在本题中,我们希望使用快排.Hash与二分实现一个简单的 O(n log^2⁡n ) 的后缀数组求法.详细地说,给定一个长度为 n 的字符串S(下标 0~n-1),我们可以用整数 k(0≤k<n) 表示字符串S的后缀 S(k~n-1).把字符串S的所有后缀按照字典序排列,排名为 i 的后缀记为 SA[i].额外地,我们考虑排名为 i 的后缀与排…
题目链接:http://poj.org/problem?id=3974 Time Limit: 15000MS Memory Limit: 65536K Description Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient…
二次方探测解决冲突一开始理解错了,难怪一直WA.先寻找key%TSize的index处,如果冲突,那么依此寻找(key+j*j)%TSize的位置,j=1~TSize-1如果都没有空位,则输出'-' #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> using namespace std; ; //之前设置…