摘要: 题意:让你把一个字符串反转,然后两个合并并去掉重复部分;就是求出末尾最长回文串; 题解:KMP;将原字符串反转,求出反转后的字符串的失配函数,然后与原字符串匹配; 参考代码: 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define clr 阅读全文
posted @ 2018-12-01 11:22 StarHai 阅读(337) 评论(0) 推荐(1) 编辑
摘要: 链接:https://ac.nowcoder.com/acm/contest/272/B来源:牛客网 题目描述 给定一棵n个点的树,每个点有权值。定义表示 到 的最短路径上,所有点的点权异或和。 对于,求所有的异或和。 输入描述: 第一行一个整数n。 接下来n-1行,每行2个整数u,v,表示u,v之 阅读全文
posted @ 2018-12-01 10:24 StarHai 阅读(403) 评论(0) 推荐(0) 编辑
摘要: Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20;Each test case consists of one strin 阅读全文
posted @ 2018-12-01 09:29 StarHai 阅读(456) 评论(0) 推荐(0) 编辑
摘要: Farmer 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 ca 阅读全文
posted @ 2018-12-01 09:24 StarHai 阅读(218) 评论(0) 推荐(0) 编辑