标签:长度 它的 har script sample style == ble gre
Time Limit: 10 Sec Memory Limit: 64 MB
Submit: 946 Solved: 653
[Submit][Status][Discuss]
对于样例,我们可以利用"abc"不断自我连接得到"abcabcabc",读入的cabcabca,是它的子串
1 #include<cstdio> 2 const int maxl=1e6+10; 3 int l; 4 int next[maxl]; 5 char ch[maxl]; 6 int main(){ 7 scanf("%d%s",&l,ch); 8 next[0]=next[1]=0; 9 for(int i=1,j;i<l;i++){ 10 j=next[i]; 11 while(ch[i]!=ch[j]&&j) j=next[j]; 12 next[i+1]=ch[i]==ch[j]?j+1:0; 13 } 14 printf("%d",l-next[l]); 15 return 0; 16 }
[Baltic2009]Radio Transmission
标签:长度 它的 har script sample style == ble gre
原文地址:http://www.cnblogs.com/J-william/p/7300450.html