内存超限不应该呀
查看原帖
内存超限不应该呀
215389
我是大帅逼69楼主2020/4/28 14:48
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
char T[1050];
int Tree_search(int s,int e)
{
	if(e-s==0)
	{
		if(T[s]=='1')
		{
			cout<<"I";
			return 1; 
		} 
		else
		{
			cout<<"B";
			return 0; 
		}
		
	}
	int n=(e+s)/2;
	int left=Tree_search(s,n);
	int right=Tree_search(n+1,e);
    if((left==2||right==2)||left!=right)
	{
		cout<<"F";
		return 2;
	}
	else
	{
		if(left==1)
		{
			cout<<"I";
			return 1;
		}
		else
		{
			cout<<"B";
			return 0;
		}
	 } 
	 
}
int main()
{
    int n;
    cin>>n;
    getchar();
    gets(T);
	int len=strlen(T);
	Tree_search(0,len-1);
	 
} 

2020/4/28 14:48
加载中...