当前位置:网站首页>再学EXKMP(EXKMP模板)
再学EXKMP(EXKMP模板)
2022-07-29 03:19:00 【愚末语】
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
string s1 ,s2 ;
cin>>s1>>s2;
vector<int>z(s1.length() + s2.length() );
auto getz = [&](string s ){
int l = 0 ;
for(int i = 1; i < s.length() ; i ++){
if(l + z[l] > i ){
z[i] = min(z[i - l] , l + z[l] - i);
}
while(i + z[i] < s.length() && s[i + z[i]] == s[z[i]])z[i] ++;
if(i + z[i] > l + z[l])l = i ;
}
};
getz(s2 + s1);
z[0] = s2.length() + 1;
ll ansz = 0 ;
for(int i = 0; i < s2.length() ; i ++){
ansz ^= (ll)1*min((int)s2.length() - i + 1, (z[i] + 1) )*(i + 1);
}
ll ansp = 0;
for(int i = 0 ; i < s1.length() ; i ++){
ansp ^= (ll)1 * min((int)s2.length() + 1, z[i + s2.length()] + 1) *(i + 1);
}
cout<<ansz<<'\n'<<ansp<<'\n';
return 0 ;
}边栏推荐
- C traps and defects Chapter 3 semantic "traps" 3.2 pointers to non arrays
- 正则表达绕过waf
- Server operation management system
- C陷阱与缺陷 第2章 语法“陷阱” 2.6 “悬挂”else引发的问题
- 12_ue4进阶_换一个更好看的人物模型
- Alibaba Sentinel - 工作流程及原理解析
- C language small project - address book (static version + dynamic version + file version)
- 04 | background login: login method based on account and password (Part 1)
- Let's talk about the summary of single merchant function modules
- "PHP Basics" output approximate value of PI
猜你喜欢

Does domestic ERP have a chance to beat sap?

Flask的创建的流程day05-06之创建项目

Self study notes on Apache file management -- mapping folders and configuring Apache virtual machines based on single IP and multi domain names

How dare you write a resume that is proficient in concurrent programming? Why do you use a two-way linked list in AQS?

接口自动化测试实践指导(上):接口自动化需要做哪些准备工作

The Federal Reserve raised interest rates again, Powell "let go of doves" at 75 basis points, and US stocks reveled

13_ UE4 advanced_ Montage animation realizes attack while walking
![[open the door to the new world] see how the old bird of testing plays API testing between applause](/img/79/1bc836cefef24d23e09d9865ff1fba.png)
[open the door to the new world] see how the old bird of testing plays API testing between applause

照片比例校正工具:DxO ViewPoint 3 直装版

【科技1】
随机推荐
12_ue4进阶_换一个更好看的人物模型
年内首个“三连跌” 95号汽油回归“8元时代“
Score addition and subtraction of force deduction and brushing questions (one question per day 7/27)
C traps and defects Chapter 3 semantic "traps" 3.4 avoid "couple method"
MYCAT read / write separation configuration
Why did I choose the test when the development salary was high?
Engineering boy: under 20 years old, ordinary but not mediocre
国产ERP有没有机会击败SAP ?
Does domestic ERP have a chance to beat sap?
MySQL operation database data error: fatal error encoded during command execution
How does DataGrid export and recover the entire database data, using a single SQL file
Minesweeping simple version
A case of gradually analyzing the splitting of classes -- colorful ball collisions
C陷阱与缺陷 第2章 语法“陷阱” 2.6 “悬挂”else引发的问题
Typescript学习(一)
Alibaba Sentinel - 工作流程及原理解析
Calculation of array serial number of force deduction questions (daily question 7/28)
Rongyun IM & RTC capabilities on new sites
Redis configuration cache expiration listening event trigger
【C】 Array