程序厌氧,求调
查看原帖
程序厌氧,求调
393199
Kali_linux楼主2023/4/6 19:39

Rt,但是可能只在你谷的测评机上发生 dev-c++开O2没事,你谷不开O2没事,你谷开02就有事了 in

CEBDAEEAACEBDAE
EBDAE

out

2
11
0 0 0 0 1 
#include<bits/stdc++.h>
int getborder(std::string str)
{
	int ans = 0;
	if(str.length() == 1)
		return 0;
	for(int i = 0; (i + 1 * 2) < str.length(); i++)
	{
		//std::cout << (str[str.length() - 0]);
		if(str[i] == str[str.length() - i - 1])
			ans++;
		else
			break;
	}
	return ans;
}
int main(void)
{
	std::string s1, s2;
	int n = 0;
	std::cin >> s1 >> s2;
	int now = 0;
	int ans = 0;
	while(now + s2.length() <= s1.length())
	{
		bool ok = true;
		bool next = true;
		int nownext = now;
		if(s1[now] != s2[0])
		{
			while(s1[now++] != s2[0]);
			now--;
		}
		//printf("%d-%d\n", now - now, s2.length());
		for(int i = now; i - now < s2.length(); i++)
		{
			//printf("%d:%d\n", i, now);
			if(s1[i] == s2[0] && next && i != now)
			{
				nownext = i - 1;
				next = false;
			}
			if(s1[i] != s2[i - now])
			{
                //printf("[line:54\ns1[i]:%c\ns2[i - now]:%c]", s1[i], s2[i - now]);
				ok = false;
			}
		}
        int t5 = ok;
        //printf("[%d]\n", t5);
		if(ok)
		{
			printf("%d\n", now + 1);
		}
		now = nownext + 1;
	}
	std::string t = "";
	for(int i = 0; i < s2.length(); i++)
	{
		t = t + s2[i];
		printf("%d ", getborder(t));
	}
	return 0;
}
2023/4/6 19:39
加载中...