思路是和线段树一样...
但就是不知道哪里错了
本地跑出来是对的
求大佬帮助,感激不尽🙏
#include <bits/stdc++.h>
using namespace std;
int n;
char tr[5000], a[1200];
#define ls (u<<1)
#define rs (u<<1|1)
void build(const int u, int L, int R) {
if(L == R) {
tr[u] = (a[L] == '0' ? 'B' : 'I');
return;
}
int M = (L+R) >> 1;
build(ls, L, M), build(rs, M+1, R);
tr[u] = (tr[ls] == tr[rs] ? tr[ls] : 'F');
}
void post(const int u) {
if(u > n<<2) return;
post(ls), post(rs);
cout << tr[u];
}
signed main() {
cout.tie(0), cin.tie(0) -> sync_with_stdio(0);
cin >> n >> a+1;
n = pow(2, n);
build(1, 1, n), post(1);
return 0;
}