⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3226574_mle.cpp

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CPP
字号:
#include <stdio.h>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

struct node
{
	char str[5003];
}res[5003];

int len;
map <string,int> h;
char s[5003], t[5003], tmp[5003];

void XOR(char a[])
{
	int i;

	for(i = 0; a[i]; i++)
	{
		tmp[i] = (a[i]-'0')^(t[i]-'0')+'0';
	}
	tmp[i] = 0;
}

int have()
{
	int t, min, max, mid;

	min = 0; max = len-1;
	while(min <= max)
	{
		mid = (max+min)>>1;
		t = strcmp(tmp,res[mid].str);
		if(t==0)
			return 1;
		else
		{
			if(t < 0)
				max = mid-1;
			else
				min = mid+1;
		}
	}
	return 0;
}

int main()
{
	int i, j, no;

	scanf("%s%s",t,s);
	len = strlen(s);
	for(i = 0; i < len; i++)
	{
		for(no = 0,j = len-i; no < len; j++,no++)
		{
			res[i].str[no] = s[j%len];
		}
		res[i].str[no] = 0;
		string tt = res[i].str;
		h[tt] = 1;
	}
	for(i = 0; i < len; i++)
	{
		XOR(res[i].str);
		string tt = tmp;
		if(h[tt]!=0)
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -