2 条题解

  • 0
    @ 2023-10-15 11:40:11
    #include <iostream>
    using namespace std;
    int n;
    char s[1<<20];
    char type  [1<<20];
    void dfs(int x){
    	if(x>=(1<<n)){
    		if(s[x]=='1'){
    			type[x]='I';
    		}
    		else{
    			type[x]='B';
    		}
    		cout<<type[x];
    		return;
    	}
    	dfs(2*x);
    	dfs(2*x+1);
    	if(type[2*x]==type[2*x+1]){
    		type[x]=type[2*x];
    	}
    	else{
    		type[x]='F';
    	}
    	cout<<type[x];
    }
    int main(){
    	cin>>n;
    	for(int i=(1<<n);i<(1<<(n+1));i++){
    		cin>>s[i];
    	}
    	dfs(1);
    	return 0;
    }
    

    信息

    ID
    672
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    递交数
    107
    已通过
    39
    上传者