9个RE,求助!
查看原帖
9个RE,求助!
1149612
gfy_uuxt_wuli_楼主2024/7/30 17:39
#include<bits/stdc++.h>
using namespace std;
#define maxn 101
int n;
char ar[maxn][3];
struct tree{
	char type,lson,rson;
	int btype=0,blson=0,brson=0;
}arr[maxn];

void tr_in(int i,int j){
	switch (j){
		case 1:{
			arr[i].type=ar[i][j];
			break;
		}
		case 2:{
			arr[i].lson=ar[i][j];
			break;
		}
		case 3:{
			arr[i].rson=ar[i][j];
			break;
		}
	}
}

void dfs(int step){
	for (int i=1;i<=2;i++){
		if (arr[step].lson=='*'&&arr[step].rson=='*'){
			arr[step].btype=1;
			cout<<arr[step].type;
			return ;
		}
		if (arr[step].type!='*'&&!arr[step].btype){
			cout<<arr[step].type;
			arr[step].btype=1;
		}
		dfs(step*2+i-1);
	}
	return ;
}

int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=3;j++){
			cin>>ar[i][j];
			tr_in(i,j);
		}
	}
	dfs(1);
	return 0;
}
2024/7/30 17:39
加载中...