F - The Minimum Length
Posted cangt-tlan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了F - The Minimum Length相关的知识,希望对你有一定的参考价值。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int len; char s[1000010]; int net[1000010]; void getnet(){ memset(net,0,sizeof(net)); net[0]=-1; int k=-1,j=0; while(j<len){ if(k==-1||s[k]==s[j]){ j++;k++; net[j]=k; } else k=net[k]; } } int main(){ while(scanf("%s",s)!=EOF){ len=strlen(s); getnet(); int tmp=len-net[len]; printf("%d ",tmp); } }
以上是关于F - The Minimum Length的主要内容,如果未能解决你的问题,请参考以下文章
Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted
hust 1010 The Minimum Length(循环节)KMP
[LeetCode] 1963. Minimum Number of Swaps to Make the String Balanced
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the short
The service already exists! The current server installed: D:mysqlmysql-5.7.30-winx64inmysqld My(代码片
ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll(代码片