ROS学习(3)

Java基础面试题(二)

  返回  

JZOJ 2021.07.20【普及组】模拟赛C组

2021/7/20 21:35:20 浏览:
题目编号标题
0排座椅(seat)
1传球游戏(ball)
2立体图(drawing)
3间谍派遣
4seek

T0 https://blog.csdn.net/weixin_44113721/article/details/118944484

T1 https://blog.csdn.net/weixin_44113721/article/details/118944693

T2 https://blog.csdn.net/weixin_44113721/article/details/118944926

T3 https://blog.csdn.net/weixin_44113721/article/details/118942809

T4 简单的KMP模板,这里之间放代码:

代码

#include <bits/stdc++.h>
using namespace std;
char s[400005];   
int next[400005],ans[400005],book[400005];          
int main()
{
	int n;
	scanf("%s",s+1);
	n=strlen(s+1);
	next[1]=0;
	int j = 0;
	for (int i=2; i<=n; i++)
	{
		next[i]=next[i-1]; 
		for (;s[j+1]!=s[i] && j; j=next[j]);
			if (s[j+1]==s[i]) j++;
		next[i]=j;
	}
	int len = 0;
	for (int i=n; i; i=next[i])
		if (next[i]>0) ans[++len]=next[i];
	ans[++len]=n;
	for (int i=1; i<=len; i++)
		book[ans[i]]++;
	memset(ans,0,sizeof ans);
	for (int i=1; i<=n; i++)
		if (book[i])
			ans[++len]=i;
	for (int i=1; i<=len; i++)
		if(ans[i])
			printf("%d ",ans[i]);
	return 0;
}

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号